Click here to Skip to main content
15,914,452 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi! i am creating a vb.net program with listbox. im populating my listbox with database values in an array. now, i want my array to store two values.. employee_id and employee_name.. i want to display employee_name and hide employee_id in my listbox.. how can i do that??
Posted
Comments
Idle_Force 12-Jun-13 23:56pm    
What platform Aspx, WPF or Winforms? That makes a big difference.

1 solution

i think below code was used for you . here i am give space between the employee name and employee code .




VB
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim empname As New ArrayList
        Dim empcode As New ArrayList
        empname.Add("arun")
        empname.Add("karthick")
        empname.Add("rajan")
        empcode.Add("100")
        empcode.Add("101")
        empcode.Add("102")
        For i = 0 To empname.Count - 1
            ListBox1.Items.Add(empname(i) & Space(200) & empcode(i))
        Next
        'retrieve
        Dim SelEmpCode As String = ""
        For i = 0 To ListBox1.Items.Count - 1
            SelEmpCode = ListBox1.Items(i).ToString.Substring(ListBox1.Items(i).ToString.LastIndexOf(" "))
            If Trim("" & SelEmpCode) = "101" Then
                ListBox1.SelectedIndex = i
            End If
        Next
    End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900