473,757 Members | 5,404 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 2111
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.addit em ("newfield")
will add an item

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

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

msgbox combobox1.list( combobox1.listi ndex)

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
1846
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 from being moved at design time. There is no direct equivalent for the Visual Basic 6.0 Locked property. What to do next Change the DropDownStyle property of the ComboBox control to DropDownList. Note In Visual Basic 6.0, setting the...
2
3054
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 DataGridTableStyle ts1 = New DataGridTableStyle() ts1.MappingName = "SchYrSemCourseJoin" ' Set other properties. ts1.AlternatingBackColor = Color.LightGray
6
3131
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 ToolbarButtons... Does anyone know how this could be done? Looking forward to hear from you,
5
3086
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 method, but in .NET's version it gives me an error, because the method no longer exists. I know I can use the Items property, but that is Read-Only at run-time. I previously used Microsoft Visual Basic 6 (not a Visual Studio component) and it...
11
6618
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 hoping that in VB2005 this would have been changed to an alphanumeric itemdata, so that no longer need to create an array "on the side" to store the key values. But I can't even find the itemdata anymore.
6
10530
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 combo. Has anyone solved this problem? Thanks
10
2091
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 disable ComboBox2. i can make this work in Visual Web Developer, but have been unsuccessful in Visual Basic 2005.
4
2161
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 problem. Can they not just post the fix. I see no reason to contact MS since I have most likely sent about 1500 dumps to them and I would think this would get their attention.
1
7594
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. What's the easy way to populate it so that each item has both a value and a text?
8
5493
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 Product column, I want to have the list of supliers that can supply the product in the combobox. At this moment I can do this in Visual Basic 2005, but the comboBox list all the supliers instead of only the supliers that can supply a certain product.
0
9487
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9884
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9735
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8736
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7285
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6556
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3828
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2697
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.