473,386 Members | 1,652 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,386 software developers and data experts.

Combo with different values in datagrid for different rows

bz
Hi,

I have a datagrid with two columns Region and City
Both have combo-boxes. City column is unbound
What I want is, when use select a region, to fill the combo for City
column with appropriate cities for that region
I did this with a code like this

private void dataGridView1_CellEnter(object sender,
DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 5) // when I step into city column
{
switch
((string)dataGridView1.Rows[e.RowIndex].Cells[1].Value) // this is
region column
{
case "NY":
this.City.Items.Clear();
this.City.Items.AddRange(
"New York",
"Alabama",
"Georgetown");
break;

case "WA":
this.City.Items.Clear();
this.City.Items.AddRange(
"Acapulco",
"Seattle");
break;

default:
this.City.Items.Clear();
this.City.Items.AddRange(
"No city available");
break;
}
}
}

But after I step in first row in column city (and the combo is
populated ok), when I move to city col in second row (where the combo
should be set to new values) app gives me the following error:
"System.ArgumentException: DataGridViewComboBoxCell valus is not
valid"

It seems this occurs everytime when I move to a row where the combo
needs to be populated with new values

How should I handle this?

Thanks
Feb 7 '08 #1
0 1240

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

Similar topics

3
by: Kevin | last post by:
Hi Al I want to add two combobox columns in my datagrid. the one combobox column must be bound to the same datasource that the datagrid is, and the other combobox I just want to populate with a...
4
by: Mike L | last post by:
I'm open for any suggestions on how to better program this. I want the user to select a license from a combo box, cboPrivilege and then the user will click the add button, then a record will be...
3
by: Doug | last post by:
Hi I have the following code (not mine) that populates a datagrid with some file names. But I want to replace the datagrid with a combo box. private void OnCurrentDataCellChanged(object sender,...
4
by: Ziv Riezman | last post by:
Hi All I Have a datagrid on asp.net. i need to add a combo box column that chages it's data according to a spefiiec row in a datagrid. Please help me ?? Thnaks Ziv Riezman
6
by: Sebastian Santacrice | last post by:
I have a few combo boxes that are multi lines and each row of data corresponds with the other combo boxed rows of data. But then they there a lot of rows one combo box scrolls down and the other...
6
by: Ron L | last post by:
I have a dataset whose source is a SQL 2k stored procedure that I am trying to display in a datagrid. This datasource has 4 columns that I am interested in here, a text column and 3 value columns...
4
by: Jim Shaffer | last post by:
Perhaps I have the wrong construct, or misunderstand arrays in vb (2003).... I've loaded a two-dimensional array (168 by 28) into memory as AcctArray. {Dim AcctArray (500,28) as string...} The...
3
by: Frustrated Developer via DotNetMonster.com | last post by:
I have posted a couple times on here already and found the user community to be very helpful. I took on a project before I realized how difficult a time I'm having working with a database....
7
by: Ausclad | last post by:
Ok, ill try again..... It seems fairly simple. I have two combo boxes in a datagrid. The datagrid is bound to a a table in a dataset. The two combo boxes are bound to a single data table...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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,...
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...

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.