x38class 0 Newbie Poster

Microsoft has the following example of how to use itemdata in .net

It works fine if you are populating row by row from 0 to whatever

I need to reset itemdata in a particular row that has been deleted,

eg
the microsoft example equates to the following

lstBox.items.add("123",654)
where 654 is the id in a database

.net allows the following without using the class
lstBox.items.add("123") which goes in row 0
lstBox.items.add("456") which goes in row 1
lstBox.items.add(1,"999") which is forced to row 1 so now we have rows 0-2

eg
"123" in row 0
"999" in row 1
"123" in row 2

How do you modify the class to achive the last example?

below is microsoft example


Public Class lstBoxes
'http://support.microsoft.com/default.aspx?scid=kb;en-us;311340

Private sName As String
Private iID As Integer 'You can also declare this as String.

'to add
'lstData.Items.Add(New lstBoxes((Trim(CStr(a))), a + 10))
' ie string & itemdata index

' to retrieve

' see PutItemData & GetItemData

' mlist = lstData.Items(lstData.SelectedIndex)
' MsgBox(mlist.Name & " * " & mlist.ItemData)
' ie string & itemdata index


Public Sub New()
sName = ""
iID = 0
End Sub

Public Sub New(ByVal Name As String, ByVal ID As Integer)
sName = Name
iID = ID
End Sub

Public Property Name() As String
Get
Return sName
End Get

Set(ByVal sValue As String)
sName = sValue
End Set
End Property

Public Property ItemData() As Integer
Get
Return iID
End Get

Set(ByVal iValue As Integer)
iID = iValue
End Set
End Property

Public Overrides Function ToString() As String
Return sName
End Function

End Class
Sub GetItemData(ByVal me_dot_lstBox As Object, ByVal me_dot_lstBox_SelectedItem As Long)


lstBox = me_dot_lstBox.Items(me_dot_lstBox_SelectedItem)
'RETURNS lstBox.Name & " * " & lstBox.ItemData

End Sub
Public Function PutItemData(ByVal me_dot_lstBox As Object, ByVal Text_String As String, ByVal Id As Long)


me_dot_lstBox.Items.Add(New lstBoxes(Trim(Text_String), Id))

End Function