| | |
Modifying Class for Insert to LstBox
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2004
Posts: 16
Reputation:
Solved Threads: 0
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
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
- Class implementation like DataTable (VB.NET)
- Set Class - Insert Function (C++)
- gtk.ListStore / gtk.ComboBoxEntry class problem (Python)
- Help with Stored Procedure (MS SQL)
- Interface page for my new database... (MySQL)
- an "(" expected?? (C++)
Other Threads in the VB.NET Forum
- Previous Thread: API of SMS
- Next Thread: Vb.net
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account arithmetic array basic beginner bing browser button buttons center check code crystalreport cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic dropdownlist excel fade file-dialog filter forms ftp generatetags google gridview hardcopy html images input insert intel internet mobile monitor net networking objects open output panel passingparameters pdf picturebox port position print printing problem save searchbox searchvb.net select serial settings shutdown soap sqlserver survey table tcp temperature text textbox timer timespan toolbox transparency trim update user vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode year





