msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

VB6 combobox and multiple columns

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Enterprise
Author Message
Bartholomew Simpson



Joined: 04 Oct 2007
Posts: 7

PostPosted: Mon Jun 18, 2007 9:12 pm    Post subject: VB6 combobox and multiple columns Reply with quote

I am populating a VB6 combo box from a UDT that contains a uniqueId
(integer) and a name (string).

I want to display only the string part (i.e the name) in the combo box).
However, when the user selects an item, I want to be able to get the
uniqueId associated with the selectes string - I've done this in the
past (so I know it can be done), but I've forgotten how to do it (Google
searches are coming up with anything remotefully useful) - anyone knows
how to do this?

Second question - can I do the same thing with a tree control ? - i.e. I
want to populate a tree structure in such a way that each node has a
uniqueId and a string (of course its only the string I want to display
in the tree). yet, when a user clicks on the tree, I want to be able to
get the associated userId - any ideas on how I may do this?

Archived from group: microsoft>public>vb>enterprise
Back to top
View user's profile Send private message
Ken Halter



Joined: 04 Oct 2007
Posts: 4150

PostPosted: Mon Jun 18, 2007 1:19 pm    Post subject: Re: VB6 combobox and multiple columns Reply with quote

"Bartholomew Simpson" wrote in message @bt.com...
>I am populating a VB6 combo box from a UDT that contains a uniqueId
>(integer) and a name (string).

ItemData?
'==============
Option Explicit

Private Sub Form_Load()
With Combo1
.AddItem "Item 1"
.ItemData(.NewIndex) = 1000
.AddItem "Item 2"
.ItemData(.NewIndex) = 1001
.AddItem "Item 3"
.ItemData(.NewIndex) = 1002
.AddItem "Item 4"
.ItemData(.NewIndex) = 1003
.ListIndex = 0
End With
End Sub

Private Sub Combo1_Click()
With Combo1
If .ListIndex >= 0 Then
Me.Caption = "Record ID = " & .ItemData(.ListIndex)
End If
End With
End Sub

Private Sub Command1_Click()
Call SelectUsingItemData(1001) 'item 2
End Sub

Private Sub SelectUsingItemData(TheData As Long)
Dim i As Integer

With Combo1
For i = 0 To .ListCount - 1
If .ItemData(i) = TheData Then
.ListIndex = i
Exit For
End If
Next
End With

End Sub
'==============

--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
In Loving Memory - http://www.vbsight.com/Remembrance.htm
Back to top
View user's profile Send private message
Dave O.



Joined: 04 Oct 2007
Posts: 580

PostPosted: Tue Jun 19, 2007 2:01 pm    Post subject: Re: VB6 combobox and multiple columns Reply with quote

Ken covered the combo box. Regarding the TreeView, you can use the id either
as part of the Key or store it in the nodes tag.

Dave O.

"Bartholomew Simpson" wrote in message @bt.com...
>I am populating a VB6 combo box from a UDT that contains a uniqueId
>(integer) and a name (string).
>
> I want to display only the string part (i.e the name) in the combo box).
> However, when the user selects an item, I want to be able to get the
> uniqueId associated with the selectes string - I've done this in the past
> (so I know it can be done), but I've forgotten how to do it (Google
> searches are coming up with anything remotefully useful) - anyone knows
> how to do this?
>
> Second question - can I do the same thing with a tree control ? - i.e. I
> want to populate a tree structure in such a way that each node has a
> uniqueId and a string (of course its only the string I want to display in
> the tree). yet, when a user clicks on the tree, I want to be able to get
> the associated userId - any ideas on how I may do this?

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
dbgrid columns HI, i'm working on dbgrid in a vb6 project, the problem is that the library for is not displayed and i don't know where to find what options i can use with this syntax, how can i view the option or make them appear in a drop down lis

populate excel columns Hello everybody I'm exporting the result of a recordset into an excel sheet using the following. oConn.Open strconnection rst.Open ssql, oConn, adCmdText Set xlrnTarget =

How to Insert a Table of Columns and Rows in Rich Textbox li How to Insert a Table of Columns and Rows in Rich Textbox and enter data in it like Microsoft Word using VB-6 ? Best Regards, Luqman

ComboBox Hi all, I am trying to get a combo box to open (similar effect to that of clicking) when a user types the first key into it. I tried using Sendkeys (Sending ALT+DOWN KEY) to simulate the effect of a click. However, this eats away the first character type

combobox goes nut Hi, This is crazy. I put a combo box on my exisiting project and put some values in the List property. The list turns to a list of "r". e.g.: type these in the List property 1 2 3 it turns to: r r r So, I close the exisiting project and start a new proje
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Enterprise All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group