Alternate of listbox.itemdata property
-
dear every one in vb 6 i used listbox.itemdata property to recognize the selected item and its reference data into other tables to fill my controls when i click on one. please help me that in vb .net how i can deal with this. i mean that i want to click on a list item for example student name and the rest record should be filled in text boxes on the form. help plz
-
dear every one in vb 6 i used listbox.itemdata property to recognize the selected item and its reference data into other tables to fill my controls when i click on one. please help me that in vb .net how i can deal with this. i mean that i want to click on a list item for example student name and the rest record should be filled in text boxes on the form. help plz
-
dear every one in vb 6 i used listbox.itemdata property to recognize the selected item and its reference data into other tables to fill my controls when i click on one. please help me that in vb .net how i can deal with this. i mean that i want to click on a list item for example student name and the rest record should be filled in text boxes on the form. help plz
hi, create following class in your application
Public Class ListItemData Dim mstrText As String Dim mintIndex As Integer Public Sub New(ByVal Text As String, ByVal Index As Integer) mstrText = Text mintIndex = Index End Sub Public ReadOnly Property Index() As Integer Get Return mintIndex End Get End Property Public Overrides Function ToString() As String Return mstrText End Function End Class
now use following code to fill listbox in your app to use above classstr = "select f_id,f_name from facultylist" result = mdGlobalInstance.GetResultFromQuery(str) 'here result is dataset For i = 0 To result.Tables(0).Rows.Count - 1 lstFaculty.Items.Add(New ListItemData(result.Tables(0).Rows(i).Item(1), result.Tables(0).Rows(i).Item(0))) Next
now get selected item of list box as followingdim id as integer id=CType(LstFaculty.SelectedItem, ListItemData).Index
hope this helpsRupesh Kumar Swami Software Engineer, Integrated Solution, Bikaner (India) My Company