Advertisement

05.10.2007 at 03:08AM PDT, ID: 22563573
[x]
Attachment Details

Manual set value of DataGridViewComboBoxCell raise exception: value is invalid

Asked by HuyBD in Microsoft Visual C#.Net, C# Programming Language, .Net Editors & IDEs

Tags: datagridviewcomboboxcell, value, invalid

Hello Experts!

I have a DataGridView grd
when add one column :
DataGridViewComboBoxColumn cl=new DataGridViewComboBoxColumn();
cl.DisplayMember="szString";//property of my object
cl.DefaultCellStyle.NullValue="Select data";
foreach(MyObject obj in MyArrayOfObject)
{
cl.items.Add(cl);
}
grd.Columns.Add(cl);
Then I add new cell of row:
DataGridViewRow row=new DataGridViewRow();
DataGridViewComboBoxCell cell=new DataGridViewComboBoxCell();
cell=(DataGridViewComboBoxCell)grd.Columns[0].CellTemplate.Clone();
cell.Value=null;//cell.Value = new MyObject("String");
row.Cells.Add(cell);
grd.Rows.Add(row);

It's work fine!

But when I set value of cell diferent of null (what in comment: cell.Value = new MyObject("String");), It's raise exception: value is invalid even the new MyObject("String") is same as one in MyArrayOfObject

Can anyone help!

Thanks in advanced!

HuyBD;
Start Free Trial
 
Loading Advertisement...
 
[+][-]05.10.2007 at 05:18PM PDT, ID: 19069327

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.10.2007 at 06:39PM PDT, ID: 19069677

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.10.2007 at 06:54PM PDT, ID: 19069731

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.10.2007 at 07:02PM PDT, ID: 19069761

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.10.2007 at 07:09PM PDT, ID: 19069795

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.10.2007 at 07:25PM PDT, ID: 19069849

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.10.2007 at 07:32PM PDT, ID: 19069866

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual C#.Net, C# Programming Language, .Net Editors & IDEs
Tags: datagridviewcomboboxcell, value, invalid
Sign Up Now!
Solution Provided By: VICKRAM
Participating Experts: 1
Solution Grade: B
 
 
[+][-]05.10.2007 at 08:08PM PDT, ID: 19069937

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.23.2007 at 08:42AM PDT, ID: 19348101

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]06.24.2007 at 07:31PM PDT, ID: 19353113

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32