List Box / Combo Box
-
Hi I want to access the items added in the list box or combo box on right click. Example List box contains: ITEM(0)"First" ITEM(1)"Second" ITEM(2)"Third" values have been populated and program is running now i "Right Click" on list box what i want , the index number of the item on which mouse was Right clicked. Thanx in anticipation
Riaz Ahmed 0300-2668545 Software Engineer DCCTechnologies riaz.ahmed@dcc.com.pk
-
Hi I want to access the items added in the list box or combo box on right click. Example List box contains: ITEM(0)"First" ITEM(1)"Second" ITEM(2)"Third" values have been populated and program is running now i "Right Click" on list box what i want , the index number of the item on which mouse was Right clicked. Thanx in anticipation
Riaz Ahmed 0300-2668545 Software Engineer DCCTechnologies riaz.ahmed@dcc.com.pk
On mouse up event of list box you can use IndexFromPoint method to get index of item which has been clicked. This index can be used to retrieve the actual listbox item, such as – ------------------------------------------ Private Sub ListBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseUp Dim ItemName As String If e.Button = Windows.Forms.MouseButtons.Right Then ItemName = Me.ListBox1.Items.Item(Me.ListBox1.IndexFromPoint(e.X, e.Y)).ToString() MessageBox.Show(ItemName) End If End Sub ------------------------------------------- I hope this helps :) . -Dave.
------------------------------------ http://www.componentone.com ------------------------------------