|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
adding listbox selected itemsHello
I'm trying to programmatically set a listbox to have several items selected when it is loaded. Which items are selected is based on a saved user setting. Right now, I'm trying: Me.my_ListBox.SelectedIndices.Add(item) This throws exceptions. What is a safe way to add indices to the SelectedIndices list? lord.zoltar,
From your example, it looks like you have the items that should be selected. In that case: Me.my_ListBox.SelectedItems.Add(item) Kerry Moorman Show quoteHide quote "lord.zol***@gmail.com" wrote: > Hello > I'm trying to programmatically set a listbox to have several items > selected when it is loaded. Which items are selected is based on a > saved user setting. > Right now, I'm trying: > Me.my_ListBox.SelectedIndices.Add(item) > This throws exceptions. > What is a safe way to add indices to the SelectedIndices list? > > You can use the ListBox control's SetSelected method. Pass it the position
of the list item, and a boolean value, True in this case. ListBox1.SetSelected(itemPosition, True) Make sure that you have also set the SelectionMode property for the control as needed. ----- Tim Patrick - www.timaki.com Start-to-Finish Visual Basic 2005 Show quoteHide quote > Hello > I'm trying to programmatically set a listbox to have several items > selected when it is loaded. Which items are selected is based on a > saved user setting. > Right now, I'm trying: > Me.my_ListBox.SelectedIndices.Add(item) > This throws exceptions. > What is a safe way to add indices to the SelectedIndices list?
IN Function ?
Recommendations - VB .Net courses/seminars another vb .net xml question PDF Creation components "Four" to 4 "Attempted to read or write protected memory" since 10 days... ADO.NET Rowfilter - between 2 dates How to deploye SQL 2005 Express with my application Call or Not Call Install errors during a Fix install |
|||||||||||||||||||||||