473,513 Members | 2,709 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ComboBox Visual Basic 2005

16 New Member
Hi I have a question about the Combo Box

This is the only Code I have seemed to be able to find to add items to a Combo Box... Is there a way to modify it or another command that I could use to have my own index or value inserted, but display the text NewField

Expand|Select|Wrap|Line Numbers
  1. Me.evSelectName.Items.Add("NewField")
So that when the click 'NewField' the value stored/read would equal something else?

Thanks in advance!
Sep 13 '07 #1
2 2101
kadghar
1,295 Recognized Expert Top Contributor
Hi I have a question about the Combo Box

This is the only Code I have seemed to be able to find to add items to a Combo Box... Is there a way to modify it or another command that I could use to have my own index or value inserted, but display the text NewField

Expand|Select|Wrap|Line Numbers
  1. Me.evSelectName.Items.Add("NewField")
So that when the click 'NewField' the value stored/read would equal something else?

Thanks in advance!
combobox1.list = Array
will add an array to your combo box

combobox1.additem ("newfield")
will add an item

if you want to know the index of the item you have selected use combobox1.listindex

lets say you want a msgbox that shows the item you've selected this could work:

msgbox combobox1.list(combobox1.listindex)

HTH
Sep 13 '07 #2
Bruno43
16 New Member
Thanks, but I guess I haven't made myself to clear and after second read of my own question it did need a little clarification

I am trying to read the Combobox items from a Database

Expand|Select|Wrap|Line Numbers
  1.  
  2.         'Build Full Employee Data Set'
  3.         Dim sql As String
  4.         Dim empDS As New DataSet
  5.         Dim maxrows As Integer
  6.         Dim inc As Integer
  7.         con.Open()
  8.         sql = "SELECT FirstName, LastName FROM Employee_table"
  9.         da = New OleDb.OleDbDataAdapter(sql, con)
  10.         da.Fill(empDS, "Employees")
  11.         con.Close()
  12.         maxrows = empDS.Tables("Employees").Rows.Count
  13.         inc = 0
  14.         Do Until inc = maxrows
  15.             Me.evSelectName.Items.Add(empDS.Tables("Employees").Rows(inc).Item("LastName") & ", " & empDS.Tables("Employees").Rows(inc).Item("FirstName"))
  16.             inc = inc + 1
  17.         Loop
  18.  
  19.  
When I do this I want to set the employee ID as the value/selected index so that in another program I can pull the Employee ID.

Thanks!
Sep 13 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1826
by: Tech | last post by:
In Visual Basic 6.0, the Locked property of a ComboBox control determined whether the text-box portion of the control could be edited. In Visual Basic ..NET, the Locked property prevents a control...
2
3041
by: jaYPee | last post by:
i have successfully added a combobox control in datagrid. this is the code i have created but don't show up the record from another table. Private Sub AddCustomDataTableStyle() Dim ts1 As...
6
3106
by: Juan Pedro Gonzalez | last post by:
I wanted to add a Combobox to a toolbar... Kind of the look you get on VisualStudio's toolbar. I've been able to find some VB 6 samples, but the placeholder option is no longer available for...
5
3066
by: Chaos2651 | last post by:
I have Visual Studio .NET with all of the components installed onto it. I want to add items to a combo box at run-time through numerous subroutines. I previously did it with the combo boxes AddItem...
11
6594
by: Martin | last post by:
Hi all! In VB6.0 A combobox had items, which basically were the description and ItemData which could be used to create a link to a record, that is if the recordset had a numeric key. I was...
6
10517
by: Roberto | last post by:
Hi, using vb 2005 I'd like to have a combobox in READONLY mode, like I have for textbox. Combobox only has enabled property. When I turn this property false I can not select the text in the...
10
2069
by: news.microsoft.com | last post by:
I am new to this so bear with me. I have a set of combo boxes. Lets call them ComboBox1 and ComboBox2. ComboBox1 items are pulled from a table. When a user selects a certain item I want to...
4
2142
by: sqlguy | last post by:
Why do we have to contact MS for a problem that has been with this compiler from at least the beta of VS 20005. I am so sick and tired of the 30 - 40 clicks it takes to dismiss VS when there is a...
1
7582
by: cowznofsky | last post by:
I was databinding to a combobox and supplying both a DisplayMember and a ValueMember, so that each item. Now I've decided against databinding, and will populate it by going through a datatable....
8
5473
by: akal483 | last post by:
Hi, I have a datagridview which has 3 columns. Product : textBox Suplier : comboBox Price : textBox Everytime I add a product to...
0
7373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.