|
-
Aug 24th, 2004, 12:43 AM
#1
Thread Starter
Hyperactive Member
Itemdata equivalent in VB.NET [Resolved]
hello everyone, i think this is fairly simple for you guys hmmm... what is the equivalent for the ItemData property of combo & list boxes in VB.NET?
Last edited by guyjasper; Aug 24th, 2004 at 04:38 AM.
-
Aug 24th, 2004, 01:21 AM
#2
SelectedValue(), I think.
-
Aug 24th, 2004, 01:33 AM
#3
Thread Starter
Hyperactive Member
you think so? so does the SelectedValue() runs in parallel with the Items property? can i assign individual value in the SelectedValue() property for each items in my combo or listbox?
-
Aug 24th, 2004, 01:48 AM
#4
Ah, I see what you mean.
Create a class which has two properties: "DisplayText" and "itemdata". Assign the values you want, and add the objects to your combobox/listbox.
-
Aug 24th, 2004, 02:12 AM
#5
Thread Starter
Hyperactive Member
ok, i quite follow you now. hmmm.... after making my class, how can i make it part of my combo box?
-
Aug 24th, 2004, 02:16 AM
#6
Like this:
VB Code:
For Each dr In ds.Tables("Products").Rows
lItem = New NameOfYourClass()
lItem.DisplayText = CInt(dr.Item("Something"))
lItem.ItemData = dr.Item("SomethingElse").ToString
ListBox1.Items.Add(lItem)
Next
-
Aug 24th, 2004, 03:26 AM
#7
Thread Starter
Hyperactive Member
i have a porblem.... the items were added fine but the text displayed in the combo box is not the value assigned to myClass.DisplayText object. The text displayed is something like this
project_name.instance_of_my_class ????
-
Aug 24th, 2004, 03:27 AM
#8
-
Aug 24th, 2004, 03:29 AM
#9
Thread Starter
Hyperactive Member
VB Code:
Public Class clsItem
Dim ItemText As String
Dim ItemID As String
Public Property DisplayText() As String
Get
DisplayText = ItemText
End Get
Set(ByVal Value As String)
ItemText = Value
End Set
End Property
Public Property ItemData() As String
Get
ItemData = ItemID
End Get
Set(ByVal Value As String)
ItemID = Value
End Set
End Property
End Class
-
Aug 24th, 2004, 03:43 AM
#10
Override String():
VB Code:
Public Class clsItem
Dim ItemText As String
Dim ItemID As String
Public Property DisplayText() As String
Get
DisplayText = ItemText
End Get
Set(ByVal Value As String)
ItemText = Value
End Set
End Property
Public Property ItemData() As String
Get
ItemData = ItemID
End Get
Set(ByVal Value As String)
ItemID = Value
End Set
End Property
Public Overrides Function ToString() As String
Return ItemText
End Function
End Class
-
Aug 24th, 2004, 04:27 AM
#11
Thread Starter
Hyperactive Member
thanks a lot man!!! It works great. cheers!!!!
-
Aug 24th, 2004, 04:29 AM
#12
Yes... cheers, jolly good and crumpets. Now add [resolved] to the thread title.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|