473,406 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

DataGridView ComboBox Problem

1
I have a DataGridView containing information of cities of the world. User can retreive records and insert record of cities from DataGridView on selection of country.

For this purpose, i have created four columns in DataGridView dynamically:
1 - S.No.
2 - Country(combo box)
3 - City Code (Edit Box)
4 - City Name (Edit box)

I have created the 'Country' column using "DataGridViewComboBoxColumn" class and populated it with DataTable using DataSource, and hence the DisplayMember is 'Country Name' and ValueMember is 'Country Code' and it is working fine at the moment. Whenever user wants to add a new city, obviously user has to select the country too which i have provided in combobox.

Now the problem is on retreiving data. I am populating the Grid manually i.e. looping row by row and inserting into each cell from a DataSet which is again working fine for all columns EXCEPT the Country column. The program gives me an exception repeatedly stating that "System.ArgumentException: DataGridViewComboBoxCell value is not valid.". I am trying to populate the Country column cell with the Country Code hoping to get the Country Name as the country name is the ValueMember BUT so far it is not letting me do that.

Kindly help me out with this problem, ill be thankful to you.
Feb 2 '12 #1
0 1452

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

Similar topics

2
by: Nathan | last post by:
Hi, I have a datagridview bound to a List of objects (ObjectA). Each ObjectA contains an ObjectB property. Class ObjectA { public ObjectB objB {} }
3
by: sklett | last post by:
I'm changing from a DataGrid to a DataGridView and have run across a problem. The items that are bound to the DataGrid have an int Property that represents a primary key of a lookup table in my...
1
by: Drakemar | last post by:
What I thought was a real simple thing to do has out not to be. I have a real simple Access database with two tables: Student Table id (autonumber) *primary key* name (text) teacherID (int)...
2
by: =?Utf-8?B?Q2hyaXMgSGxhZGU=?= | last post by:
I am trying to do something that I would think would be easy. I have a dataset that is filled from an XML file. For simplicity, let's say there are two tables: - Table Customer has fields...
0
by: BiT | last post by:
Hello i'm using the datagridview control in vb.net. one of the column is combobox i worte this code to enter value to the combobox Dim _messageId As New DataGridViewComboBoxCell ...
1
by: Trey | last post by:
I have an unbound datagridview with three comboboxes (e.g. A, B, C) All three comboboxes share the same datasource and use the same valuemember. If I change the value of say combobox A, then B and...
0
by: Dom | last post by:
I have a datagridview control, and one column is a ComboboxColumn. I simply create a ComboboxColumn, add items to it, then add the column to the Datagridview control. If I were working with a...
0
by: HDI | last post by:
Hi, I'm using vb.net express 2005 and I've got a project where I use a datagridview with a combobox in the first column. Depending on the value the user selects I have to set values of other...
0
by: priyamtheone | last post by:
There's an editable datagridview populated from a table say tblItems. Among the columns of the datagridview there's a combobox column named 'Category'. This column is populated by the respective...
0
by: visweswaran2830 | last post by:
Hi, I am having datagridview in that I have datagridview combobox column and noraml textfield. I want to know that how can I load selected value in that combox box when I am loading all entered...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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
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,...
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...

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.