473,809 Members | 2,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

simple combo question

Tim
it must be tempting to say FTFM, but believe me I have.

I have a combobox.
I set Co.ValueMember = "field1"
and Co.DisplayMembe r = "field2"

and then load some data this way

Co.DataSource = DS.Tables(1)

so far so good, I now have a combo filled with data.

Now all I need to do is move the combo to an item with code, based on
the ValueMember.

I guessed something like
Co.SelectedValu e = "123"

No joy. I have loads of other things as well.

Any tips?

Apr 27 '06 #1
5 997
It will help if you tell us what version of .NET you are using as 2.0
has some new methods that will help you in this task, and 1.1 does
not...
lp
Jan
http://cwizo.blogspot.com

Apr 27 '06 #2
Tim
..net2 (vs2005)

thanks

Apr 27 '06 #3
Tim
if anyone is interested, I have found the answer to my problem!!!

Co.SelectedValu e = "123" does indeed work,

However, if you create a new combo at runtime, set the selectedvalue,
and then add it to the form, it fails. If you create a new combo at
runtime, then add it to the form, then set the selectedvalue, it works
fine!

Not sure if this is obvious behaviour or not. Oh well, I'll file it
under Q for quirky.

Apr 27 '06 #4
You can select a item by its value like this:

Me.comboBox.Ite ms.FindByValue( YourValue.ToStr ing()).Selected = True

--
Lp
Jan
http://cwizo.blogspot.com

Apr 28 '06 #5
On 27 Apr 2006 14:40:16 -0700, "Tim" <Ci************ @gmail.com> wrote:
if anyone is interested, I have found the answer to my problem!!!

Co.SelectedVal ue = "123" does indeed work,

However, if you create a new combo at runtime, set the selectedvalue,
and then add it to the form, it fails. If you create a new combo at
runtime, then add it to the form, then set the selectedvalue, it works
fine!

Not sure if this is obvious behaviour or not. Oh well, I'll file it
under Q for quirky.


I belive the drop down list doesn't bind to its data until it's been added to a form. A limitation due to
BindingContext?
Apr 29 '06 #6

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

Similar topics

3
7271
by: Aamir | last post by:
Hi, Quick Question: How to create a simple XML with US States list and read it into a combo box. Detail: I am very new to Dot Net technology as well as xml. I am building a desktop app in C# and need to populate the US States list (AL, AR, .. WY) in a combo box. I could have done it by reading
3
2014
by: NB | last post by:
Let's say in the product table I have around 50,000 products (well, infact it has now about 2000 only, but it's growing very fast, hence the question here) In the order form, users will select the product for the order lines. They want to see the entire list of available products. You can't handle the combo the way you've heard: limiting rowsource until first few characters entered, because - the product primary key is an autonumber
1
1253
by: Greg Acuna | last post by:
I've been using Access 2002 for several months and thought I was getting proficient, but at the moment I'm feeling like a moron because I can't get it to do something that seems simple. I have a main table that has most of my database. Then I have a "Groups" table which I want to use to group the main database by a sub-heading. I have a "GroupID" Field in both tables and I have them linked in the Relationships table. When I set up a...
4
2077
by: d.p. | last post by:
Hi all, I'm using MS Access 2003. Bare with me on this description....here's the situation: Imagine insurance, and working out premiums for different insured properties. The rates for calculating premiums are dependant on the country in which the client is in. Therefore, we have a Country table, with its list of rates, a client table and then the property table. Getting this is great, works fine, easy! Problem is, now I need to work out a...
8
18401
by: Lyn | last post by:
Hi, Can anyone tell me how the initial value displayed in Combo Box is determined when a form is opened? I am loading the dropdown from one field ("CategoryName") of a table, with "ORDER BY ". The values in the dropdown are loaded in the correct order, but the initial value is not the first row of the dropdown as I expected. The field "CategoryName" is not the primary key for the table -- the PK is
14
3117
by: alwayshouston | last post by:
Hi All! I am working on this very small database and I am confused in the designing a simple form. I only have three tables in the database. First Table: tblExpense Columns: ExpenseID ; ExpenseType Data: 1 ; FOOD 2 ; AIRLINE 3 ; FARE
7
1073
by: Tim | last post by:
hi all, a simple OO related question... I have some controls. Say, a textbox, a combo and a datepicker. They all share some properties (tag, size etc). How should I add another shared property to them all? Eg a property called "RequiredField" so I can go textbox.requiredfield=true, combo.requiredfield=false etc etc
1
2580
by: Shawn Yates | last post by:
It has been a while since I have done anything on MS Access and I seem to be a bit rusty. I hope someone could help me solve my issue. I have a form that has multiple combo boxes on it. Each box has 4 possible answers to a question. Each of the 4 possible answers is also assigned a value: answer 1 is worth 1 point, answer 2 is worth 2 points.... What I need to do now is add togethor the points of all the combo boxes. So far I have given...
2
3147
by: Sid | last post by:
I need some help in setting up Access combo box. I am using three comboboxes in my form. Comb Box 1, Combo Box 2, Combo Box 3. The row source for each of the combo box is a seperate table. Table 1 acts as row source for Combo Box 1 Table 2 acts as row source for Combo Box 2 However for combobox 3, I was trying to use 4 different tables as row source. I am trying to set up a criteria such that row source for comb
3
2490
by: deejayquai | last post by:
Hello Simple one this I guess, but I'm quite stuck at the moment. I would like to update the records displayed in my listbox (lstStudents) using criteria selected from my combo (cboForm) in a form. My basic code is:
0
9600
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
10633
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
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10375
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
10114
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...
1
7651
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
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3860
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
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.