943,962 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 2599
  • VB.NET RSS
Feb 9th, 2005
0

Modifying Class for Insert to LstBox

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
x38class is offline Offline
24 posts
since May 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: API of SMS
Next Thread in VB.NET Forum Timeline: Vb.net





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC