By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,682 Members | 1,376 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,682 IT Pros & Developers. It's quick & easy.

Listbox issue

P: n/a
Hi all,

How can I hide an id column in the listbox and the combobox???

I'm puting the PK into the text, like this:

Books(1)
CD(2)

how can I hide these codes???

Thanks in advance,

Fábio Augusto
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
* "Fabio" <fa***@glb.com.br> scripsit:
How can I hide an id column in the listbox and the combobox???

I'm puting the PK into the text, like this:

Books(1)
CD(2)

how can I hide these codes???


Are you talking about a databound listbox/combobox?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #2

P: n/a
yes,

how can I solve this???

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bm************@ID-208219.news.uni-berlin.de...
* "Fabio" <fa***@glb.com.br> scripsit:
How can I hide an id column in the listbox and the combobox???

I'm puting the PK into the text, like this:

Books(1)
CD(2)

how can I hide these codes???


Are you talking about a databound listbox/combobox?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Nov 20 '05 #3

P: n/a
Fabio

I understand when the user clicks the listbox you want to
look up a reference number stored with the text

In VB6, ItemData would have done this. In VB.Net, you can
do something much more powerful. You can put objects in
your list. In the example below, I've set up a structure
which has a text item (to go in the list) and an index
item. Note I've included an interface so the items can be
sorted in the listbox.

'structure to hold info to go in list
Structure ListStructure
Implements IComparable 'for sort

Dim Text As String
Dim Index As Integer

Sub New(ByVal sText As String, ByVal sIndex As
Integer)
Text = sText
Index = sIndex
End Sub

Overrides Function ToString() As String
Return Text
End Function

'this bit handles sort
Public Function CompareTo(ByVal obj As Object) As
Integer Implements System.IComparable.CompareTo
Return StrComp(Text, DirectCast(obj.text,
ListStructure).Text)
End Function

End Structure

'this is how you add items
str = New ListStructure(xText, xIndex) : cmbList.Items.Add
(str)
'..end loop

'this is how you retrieve items
'get the text
Dim tText as Integer= DirectCast(cmbList.Items
(cmbList.SelectedIndex), ListStructure).Text
'get the index
Dim tIndex as Integer= DirectCast(cmbList.Items
(cmbList.SelectedIndex), ListStructure).Index
Dermot Balson
Free VBA code for user interfaces, internet connectivity,
encryption
http://www.webace.com.au/~balson/Ins...l/Default.html
Last updated August 2003
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.