CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: what's wrong ??

  1. #1
    Join Date
    Sep 1999
    Location
    Pacific Ocean, Deep Blue Sea
    Posts
    133

    what's wrong ??

    hi,
    all i want to do is just to get the selected content in List A and move them to List B
    and i end up this piece of code b4 i can compile successfully.

    int[] selectedData ;
    Object[] objData ;

    String cmd = e.getActionCommand();
    if( cmd.equals( "hide" ) == true )
    {
    selectedData = regtrList.getSelectedIndices() ;
    objData = new Object[selectedData.length] ;
    for (int i=0; i<selectedData.length; i++)
    objData[i] = Integer.toString(selectedData[i]) ;
    filterList.setListData(objData) ;
    }





    any1 dare to tell me what stupid mistake i made here ?

    thank u

    Signature (up to 100 characters) You may use Markup in your signature

  2. #2
    Join Date
    Jan 2000
    Location
    Canada
    Posts
    249

    Re: what's wrong ??

    The only thing I can see wrong right now is that you're trying to take an array (the whole array, not each element) and output it as a string. To fix this, change the following line:
    objData = Integer.toString(selectedData);


    to
    objData = Integer.toString(selectedData[i]);



    -------------------------------------------
    weaver
    icq# 64665116
    Please rate this post.
    http://weaver.x7.htmlplanet.com

  3. #3
    Join Date
    Sep 1999
    Location
    Madurai , TamilNadu , INDIA
    Posts
    1,024

    Re: what's wrong ??


    When you post a question , please explain your problem clearly. Are u getting any compiler
    or runtime error ? Or are u getting unwanted result ???

    > for (int i=0; i<selectedData.length; i++)
    > objData = Integer.toString(selectedData) ;

    I dont know whether it's codeguru forum site bug or you are actually trying to do this.
    ( dont use "["i"]" , it will be interpreted as "<"i">" tag in HTML )

    If your code is something like the following,


    for (int index=0; index<selectedData.length; index++)
    objData[index] = Integer.toString(selectedData[index]) ;




    You are trying to assign the indexes not the values from the "regtrList". If you want
    the values , you have to do something like the following


    objData[index] = regtrList.getItem().(selectedData[index]) ;




    Poochi..


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured