473,671 Members | 2,228 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with VB.NET Combobox

Hi,

Is there any way to access the values (not display names)of a combobox ?

For example:

combo1.DataSour ce = dataset1.tables (0)
combo1.DisplayM ember = "Name"
combo1.ValueMem ber = "ID"

I want to iterate thru the values of the combobox inside my code , but
somehow there is not property for values, i.e. "combo1.Items(1 ).value "

In ASP.NET, the combobox does have that property but in VB.NET, the combobox
lacks that property.

Does anybody know of any way to iterate thru values in a combobox ?

Thanks,
Hang

Dec 21 '06 #1
6 5284
Scott,

There is no need to iterate through the combobox, the datasource of that is
much easier to use (in fact your table(0)..

If you tell us what you want to achieve than we can help you probably more
exact because the possibilities to get a value are almost endless with that.

By the way, did you know that there is a better newsgroup for questions like
this.
Microsoft.publi c.dotnet.langua ges.vb

Cor

"Scott Lam" <Sc******@discu ssions.microsof t.comschreef in bericht
news:97******** *************** ***********@mic rosoft.com...
Hi,

Is there any way to access the values (not display names)of a combobox ?

For example:

combo1.DataSour ce = dataset1.tables (0)
combo1.DisplayM ember = "Name"
combo1.ValueMem ber = "ID"

I want to iterate thru the values of the combobox inside my code , but
somehow there is not property for values, i.e. "combo1.Items(1 ).value "

In ASP.NET, the combobox does have that property but in VB.NET, the
combobox
lacks that property.

Does anybody know of any way to iterate thru values in a combobox ?

Thanks,
Hang

Dec 21 '06 #2
Hi Cor,

I set-up a combobox in the Form Load event:

in the Form_Load event
combo1.DataSour ce = dataset1.tables (0)
combo1.DisplayM ember = "Name"
combo1.ValueMem ber = "ID"

Then I do a search for a record which return an ID .. the ID represents the
value of the combobox's item that needs to be selected.

How do I compare the value returned in my query to the values in the
combobox ?

Thanks,
Hang

"Cor Ligthert [MVP]" wrote:
Scott,

There is no need to iterate through the combobox, the datasource of that is
much easier to use (in fact your table(0)..

If you tell us what you want to achieve than we can help you probably more
exact because the possibilities to get a value are almost endless with that.

By the way, did you know that there is a better newsgroup for questions like
this.
Microsoft.publi c.dotnet.langua ges.vb

Cor

"Scott Lam" <Sc******@discu ssions.microsof t.comschreef in bericht
news:97******** *************** ***********@mic rosoft.com...
Hi,

Is there any way to access the values (not display names)of a combobox ?

For example:

combo1.DataSour ce = dataset1.tables (0)
combo1.DisplayM ember = "Name"
combo1.ValueMem ber = "ID"

I want to iterate thru the values of the combobox inside my code , but
somehow there is not property for values, i.e. "combo1.Items(1 ).value "

In ASP.NET, the combobox does have that property but in VB.NET, the
combobox
lacks that property.

Does anybody know of any way to iterate thru values in a combobox ?

Thanks,
Hang


Dec 21 '06 #3
Scott one example written in this message so watch typos
in the Form_Load event
combo1.DataSour ce = dataset1.tables (0).DefaultView
dataset1.tables (0).DefaultView .Sort = "Name"
combo1.DisplayM ember = "Name"
combo1.ValueMem ber = "ID"
combo1.Selected Idex = dataset1.tables (0).Defaultview .Find("Scott")

Know that in this case the selectedindexch ange event is firing.

Cor
Dec 21 '06 #4
valuetocompare = combo1.selected value
"Scott Lam" <Sc******@discu ssions.microsof t.comwrote in message
news:D4******** *************** ***********@mic rosoft.com...
Hi Cor,

I set-up a combobox in the Form Load event:

in the Form_Load event
combo1.DataSour ce = dataset1.tables (0)
combo1.DisplayM ember = "Name"
combo1.ValueMem ber = "ID"

Then I do a search for a record which return an ID .. the ID represents
the
value of the combobox's item that needs to be selected.

How do I compare the value returned in my query to the values in the
combobox ?

Thanks,
Hang

"Cor Ligthert [MVP]" wrote:
>Scott,

There is no need to iterate through the combobox, the datasource of that
is
much easier to use (in fact your table(0)..

If you tell us what you want to achieve than we can help you probably
more
exact because the possibilities to get a value are almost endless with
that.

By the way, did you know that there is a better newsgroup for questions
like
this.
Microsoft.publ ic.dotnet.langu ages.vb

Cor

"Scott Lam" <Sc******@discu ssions.microsof t.comschreef in bericht
news:97******* *************** ************@mi crosoft.com...
Hi,

Is there any way to access the values (not display names)of a combobox
?

For example:

combo1.DataSour ce = dataset1.tables (0)
combo1.DisplayM ember = "Name"
combo1.ValueMem ber = "ID"

I want to iterate thru the values of the combobox inside my code , but
somehow there is not property for values, i.e. "combo1.Items(1 ).value "

In ASP.NET, the combobox does have that property but in VB.NET, the
combobox
lacks that property.

Does anybody know of any way to iterate thru values in a combobox ?

Thanks,
Hang



Dec 21 '06 #5
Cor,

Thanks for you help .
It does the trick , the only downside is that I have to keep the dataset
alive and not destroyed it once I populate the combo box.
I wish Microsoft would just add a "values property" to the VB.NET Combobox
like in ASP.NET

Anyways, thank you.

hang

"Cor Ligthert [MVP]" wrote:
Scott one example written in this message so watch typos
in the Form_Load event
combo1.DataSour ce = dataset1.tables (0).DefaultView
dataset1.tables (0).DefaultView .Sort = "Name"
combo1.DisplayM ember = "Name"
combo1.ValueMem ber = "ID"
combo1.Selected Idex = dataset1.tables (0).Defaultview .Find("Scott")

Know that in this case the selectedindexch ange event is firing.

Cor
Dec 22 '06 #6
Scott,

Why should you destroy it, keep in mind that there are big differences in
developing for the web and developing winforms, despite some tales seem to
tell.

Cor

"Scott Lam" <Sc******@discu ssions.microsof t.comschreef in bericht
news:1F******** *************** ***********@mic rosoft.com...
Cor,

Thanks for you help .
It does the trick , the only downside is that I have to keep the dataset
alive and not destroyed it once I populate the combo box.
I wish Microsoft would just add a "values property" to the VB.NET Combobox
like in ASP.NET

Anyways, thank you.

hang

"Cor Ligthert [MVP]" wrote:
>Scott one example written in this message so watch typos
in the Form_Load event
combo1.DataSour ce = dataset1.tables (0).DefaultView
dataset1.table s(0).DefaultVie w.Sort = "Name"
combo1.DisplayM ember = "Name"
combo1.ValueMem ber = "ID"
combo1.Selecte dIdex = dataset1.tables (0).Defaultview .Find("Scott")

Know that in this case the selectedindexch ange event is firing.

Cor

Dec 22 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
2357
by: Jack Schitt | last post by:
I thought I was starting to get a handle on Access, until I tried doing something useful...now I'm stuck. I have a DB with two tables - to keep it simple I'll say that one is an Employee File (Employees), and the other is an Address File (Addresses) linked by SSN. I've set Addresses as a Lookup Table - If the user starts typing in the SSN it should pull up the Employees records. I'm getting stuck in the Data Entry form. When I type in...
11
2796
by: my-wings | last post by:
I think I've painted myself into a corner, and I'm hoping someone can help me out. I have a table of books (tblBooks), which includes a field (strPubName) for Publisher Name and another field (strPubCity) for Publisher City. These two fields have a many-to-one relationship with tables, (tlkpPubName and tlkpPubCity) respectively. The lookup tables only have one field (strPubName and strPubCity), which is their primary key. I also have...
23
3263
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application to create certain textboxes, labels, and combo boxes? Any ideas would be appreciated. Thanks
1
2492
by: anonymous | last post by:
I've been trying to put a them, please help me out. Here's the major parts of my code: public Form1() { DataSet myDataSet = new DataSet("myDataSet"); DataTable testTable = new DataTable("table"); testTable.Columns.Add("Col1", typeof(Int32)); testTable.Columns.Add("Col2", typeof(String)); testTable.Rows.Add(testTable.NewRow());
6
1593
by: Jean Christophe Avard | last post by:
Hi! I'm designing an application that produces invoices. I have a combobox that is populated with the Name of every client in the database. What I would like to do is to have the combobox to display the name, and to have the value set to the ID of the record... Like in HTML where you have something like: <option value="ID_NUMBER(primary key)">CLIENT_NAME</option> so, let's say the user selects "Client #2" in the combo box, then I would...
4
4613
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box bound to a table as a lookup, drawing values from another table to populate the available selections. This all worked fine in VB6. I have distilled the problem down to a simple form drawing data from the Northwind database for a representative...
22
2177
by: KitKat | last post by:
I need to get this to go to each folders: Cam 1, Cam 2, Cam 4, Cam 6, Cam 7, and Cam 8. Well it does that but it also needs to change the file name to the same folder where the file is being grabbed, BUT it doesn't. I have tried and tried.....please help example: C:\Projects\Darryl\Queue Review Files\2-24\Cam 7\Cam7-20060224170000-01.jpg Cam7 but all I keep getting is Cam1, as the beginning of the jpg name,...:( HELP!
3
1966
by: Rick Shaw | last post by:
Hi. I am very new to C# and needed help. Use to program in Delphi but switching to C#. I am just starting my very first application and already don't know what to do. Here is what I'm trying to do. I have 2 comboboxes. 1st combobox is filled (dataset binding) with list of companies from the form load. The 2nd combobox, contain list (filled from dataset then bind) of employees where each employee belongs to a specific company. So,...
0
2225
by: BigAl.NZ | last post by:
Hi Guys, I am trying to write/copy some code that uses events with a GPS. Everytime the GPS position updates the event fires. The GPS code is from a SDK Library that I got called GPS Tools from www.franson.com For some reason my code below doesnt work - the GpsFixEvent never seems to "fire" as it were.
0
8473
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...
0
8390
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8911
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8667
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
7428
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
6222
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
4402
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1806
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.