CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2000
    Location
    Tallahassee, FL
    Posts
    121

    List Box AddItem Method

    hopefully this will be a quick (easy question)

    ok my list box is sorted so when i add an item via AddItem i want to know what index it added it to because i need to set the ItemData for that new index i just added

    i thought i coulde do the following..

    dim newIdx as integer
    newIdx = list.AddItem "Text"

    list.ItemData( newIdx ) = ID

    any suggestions as to how i can do something like the code above?

    thankx,


  2. #2
    Join Date
    Jan 2000
    Posts
    11

    Re: List Box AddItem Method

    You can get the index oof the most recently added item in a listbox by getting the property NewIndex of the list control, for example:

    dim myIndx as long
    List1.Clear
    List1.AddItem "ABC"
    List1.AddItem "ZXY"
    List1.AddItem "EFG"
    myIndx = list1.NewIndex
    ' myIndx contains the index number of EFG wich is 2



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