|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
SetFocus!Clicking different CommandButtons on a VB6 Form adds the Captions of
the CommandButtons as items in a ListBox one below the other. For e.g. when a user clicks the CommandButton "5", "5" gets added as the 1st item in the ListBox. Next when the user clicks the CommandButton "2", "2" gets added as the 2nd item in the ListBox below "5" so on & so forth. I want that when an item gets added to the ListBox, that item should get highlighted/selected. For e.g. when "5" gets added to the ListBox, "5" should be highlighted/selected. Next when "2" gets added to the ListBox (below "5"), "2" should be highlighted/selected. How do I do this? Thanks, Arpan "Arpan" <arpan***@hotmail.com> wrote in message list1.additem command1.captionnews:1128695676.999279.242310@g14g2000cwa.googlegroups.com > Clicking different CommandButtons on a VB6 Form adds the Captions of > the CommandButtons as items in a ListBox one below the other. For e.g. > when a user clicks the CommandButton "5", "5" gets added as the 1st > item in the ListBox. Next when the user clicks the CommandButton "2", > "2" gets added as the 2nd item in the ListBox below "5" so on & so > forth. I want that when an item gets added to the ListBox, that item > should get highlighted/selected. For e.g. when "5" gets added to the > ListBox, "5" should be highlighted/selected. Next when "2" gets added > to the ListBox (below "5"), "2" should be highlighted/selected. How do > I do this? list1.selected(list1.newindex)=True -- Reply to the group so all can participate VB.Net: "Fool me once..." "Arpan" <arpan***@hotmail.com> wrote in message ' List1.AddItem( "2" )news:1128695676.999279.242310@g14g2000cwa.googlegroups.com... > For e.g. when "5" gets added to the ListBox, "5" should be > highlighted/selected. Next when "2" gets added to the ListBox > (below "5"), "2" should be highlighted/selected. > How do I do this? List1.ListIndex = List1.NewIndex HTH, Phill W. "Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message Yep, I stopped reading at "highlighted" and missed "selected"news:di64bq$aji$1@yarrow.open.ac.uk > "Arpan" <arpan***@hotmail.com> wrote in message > news:1128695676.999279.242310@g14g2000cwa.googlegroups.com... >> For e.g. when "5" gets added to the ListBox, "5" should be >> highlighted/selected. Next when "2" gets added to the ListBox >> (below "5"), "2" should be highlighted/selected. >> How do I do this? > > ' List1.AddItem( "2" ) > List1.ListIndex = List1.NewIndex -- Reply to the group so all can participate VB.Net: "Fool me once..." Bob, the code you provided also selects/highlights the just added item
to the ListBox; so what difference does it make if I use your code or Phill's code as both the codes do the needful. Thanks once again & thanks to Phill as well. Regards, Arpan "Arpan" <arpan***@hotmail.com> wrote in message Set the .MultiSelect option of the listbox to allow multiple selections andnews:1128702322.932624.15400@o13g2000cwo.googlegroups.com > Bob, the code you provided also selects/highlights the just added item > to the ListBox; so what difference does it make if I use your code or > Phill's code as both the codes do the needful. > > Thanks once again & thanks to Phill as well you'll see a difference. Mine selects each item; Phil's sets the currently selected item to be the newest item. Both are useful but it depends on what you want. -- Reply to the group so all can participate VB.Net: "Fool me once..." |
|||||||||||||||||||||||