ent_ttu
Member
- Joined
- Jun 17, 2008
- Messages
- 14
- Programming Experience
- 1-3
I've created a custom class that inherits ListBox. I'm successfully able to create the box and have it appear on the page I need (thanks to help from this forum), but now I can't get it to select a specific item as the default.
I've created an array that stores the values, so I can keep both the primary key and the information I want the user to see. I konw the data is being passed, because the box appears with the names in it, and I can get a pop-up window with the primary key.
I've tried everything I can find online, but none of it's working. Here's the code snippets:
I'm using VB.NET 2005. Any suggestions would be much appreciated. Thanks in advance!
I've created an array that stores the values, so I can keep both the primary key and the information I want the user to see. I konw the data is being passed, because the box appears with the names in it, and I can get a pop-up window with the primary key.
I've tried everything I can find online, but none of it's working. Here's the code snippets:
VB.NET:
Dim lstRespParty As New ListBox
Public Sub New(ByVal responsibleID As String, ByVal ParentForm As Form)
Dim people As New ArrayList()
'There's a sql query here to get people from table, but I didn't post it
Do While inc < MaxRows
resp = New responsibleParty(ds.Tables("ppl").Rows(inc).Item("person_id"))
people.Add(resp)
inc = inc + 1
Loop
lstRespParty.DataSource = people
'when I run the code, the integer appears in this msgbox, so I know it's being passed
MsgBox("responsible id: " & responsibleID)
lstRespParty.DisplayMember = "rpLastNameFirst"
lstRespParty.ValueMember = "personNo"
'this is where I'm trying to tell it to choose the responsibleID when it displays the list box
lstRespParty.SelectedValue = responsibleID
'tried selectedvalue = responsibleID
'tried selectedvalue = "responsibleID"
'tried selecteditem = responsibleID
'tried selecteditem = "responsibleID"
'tried selectedindex = responsibleID; at least got an error message
'lstRespParty.SelectedIndex = "responsibleID"; at least got an error message
I'm using VB.NET 2005. Any suggestions would be much appreciated. Thanks in advance!