This is a migrated thread and some comments may be shown as answers.

Get Index of a RadListBoxItem

2 Answers 103 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Denny
Top achievements
Rank 1
Denny asked on 05 Nov 2009, 03:47 PM
Hello,

how can I get the Index of a RadListBoxItem in a RadListBox?

My current code:
Dim myItem As New RadListBoxItem  
AddHandler myItem.Click, AddressOf Me.ListBoxClick  
Me.RadListBox1.Items.Add(myItem)  
 
 
Private Sub ListBoxClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)       
 
        Dim myItem As RadListBoxItem = sender   
        Dim myIndex As Integer = ???    <---- How can I get the index?   
 
        Me.RadListBox1.SetSelected(myIndex, True)  
End Sub  
 
 
 
 
 
 

 

 

 

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Denny
Top achievements
Rank 1
answered on 05 Nov 2009, 04:03 PM
Got it:

 

 Dim myIndex As Integer = Me.RadListBox1.Items.IndexOf(myItem) 

 

0
Robert
Top achievements
Rank 1
answered on 09 Nov 2009, 06:04 PM
Hi Denny,

If you are interested in getting the index of a RadListBoxItem when it is clicked you should be able to use the SelectedIndexChanged event of the RadListBox as well.

    Private Sub RadListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadListBox1.SelectedIndexChanged 
        Dim myIndex = RadListBox1.SelectedIndex 
 
    End Sub 

- Robert


Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Denny
Top achievements
Rank 1
Answers by
Denny
Top achievements
Rank 1
Robert
Top achievements
Rank 1
Share this question
or