473,465 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Placing Value Member of a combo box in the Display Member of another

5 New Member
I have been battling with this problem for months with virtually no success.

I am using Visual Studio 2008 Professional. The database is Microsoft SQL 2005.

I have an unbound datagridview with two combo boxes – both bound to database tables. These are:

Combo box 1 is for “VAT” and is bound to the VAT table. This table has 3 columns configured as shown below:

ID VAT Code VAT Percentage

1 N 0.00
2 S 20.00
3 1 5.00


The second combo box is for “Category” and looks like this:

ID Category VAT Code

1 Domestic fuel 1
2 Office equipment S
3 Travel S

Combo box 1’s configuration on Form 1’s Design View is:
Data source is VATTableBindingSource
Display Member is VAT Code
Value Member is VATPercentage

Combo box 2’s configuration on Form 1’s Design View is:
Data source is CategoryBinding Source
Display Member is Category
Value Member is VATCode

The Category table will obviously have many more categories but only 3 have been shown for clarity.

My problem is “How do I automatically pass the Value Member of combo box 2 to the Display member of combo box 1 after selecting the Category in combo box 2?

The reason for doing things this way is that it is so much cleaner to perform updates when the VAT percentage changes – one entry in the VAT table and not dozens of entries in the Category table which is prone to error. In addition to this, there are always exceptions to the rule. For example, the “Travel” category can have two values of VAT. 20% for hotel bills and zero percent for train fares. By default, it would have “S” but if I am entering a train fare, I want to use combo box 1 to change the VAT code to “N” so that the calculations are done correctly.

All of the above has so far been done using the “drag and drop” method of placing controls onto the design surface and adding the data binding, etc., there.

I have this working with 2 stand alone combo boxes using the code:

CODE/ Combobox1.SelectedIndex = ComboBox1.FindString(Combobox2.SelectedValue) /CODE

There must be a simple way to do this in a DataGridView – one or two lines of code? I just cannot find it. Any suggestions????


Mike Newman
Jan 20 '12 #1
0 886

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

Similar topics

2
by: Aaron Ackerman | last post by:
Is there any way to concatenate a display member in a bound combo (ex: FirstName & LastName) or do I merely have to have a field called FullName in my dataset from the get go and bring that over???
3
by: jut_bit_zx | last post by:
class A { public: A(); virtual ~A(){} .... private: int m_iarray; }
8
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 ". ...
2
by: Hanumanth Reddy | last post by:
Any one could help how to bind two table field values into combobox display member property. I mean i have two fields in a table. One is states description and another is states codes.I want to...
2
by: ABC | last post by:
How to pre-set combo textbox's selectedindex value from querystring passed from another page? I pass the querystring to set combo text box (change selectedindex on Page_Init). Source code as: ...
6
by: Harshil | last post by:
I am developing an application in vb.net and oracle as my database. my goal is to display the county names (display member) to the user while store county id (value member) in the combo box. when I...
2
by: AMDRIT | last post by:
Hello Everyone, I would like to format the Display Members of a combobox's datasource. Is there a way to apply a format without subclassing the original datasource? For example, given a list of...
7
by: sara | last post by:
I have a form where the user selects an item from a list box, and then works on that item. The user chooses an AD, then opens a form to assign departments to the ad. The top of the Depts form has...
0
by: Amit | last post by:
Hi All, Can any one write me the Code to sort datagridviewcomboboxcolumn according to display member property. By default is it sorted according to value member but I want to sort according to...
0
by: questionit | last post by:
I have a value in Combo Box. If combo box is expanded, i want to display the current value in its window when its opened. I have tried doing it, but its value doesn't appear in its window. Is...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
1
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...
0
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.