I Have a simple datagridview bound to a database. One of the columns is a comboxcolumn.
When i try to drop down the combobox in any row i get the following error.
"Getting the Size property of a cell in a shared row is not allowed."
Any idea what causes this error Any solution yet
I am using Beta 1 (Feb 2005 CTP).

DataGridView Combobox Column
davidt1234
I got another one for ya.
I have a datagridview with 2 columns. This datagridview is bound to a datatable.
The first columns DataGridViewCellStyle.Format property is set to C2 (Currency).
The first columns DataGridViewCellStyle.Format property is set to P2 (Percentage).
When I edit the values in the datagridview for the currency column it works and the changes are made to the datatable normally.
When I edit the values for the percentage colums I get the following error.
"Input string was not in the correct format."
It seems there is a problem converting the cells string to a decimal value for storage in the datatable.
I have tried to handle the DataGridView.CellParsing event and removing the "%" from the string but that does not work.
The only work around I have found for this bug is to do the following.
When the user clicks edit I remove the format from the column.
MyGrid.Columns["DiscountRate"].DefaultCellStyle.Format = "";
When the user saves the information I put the format back.
MyGrid.Columns["DiscountRate"].DefaultCellStyle.Format = "P2";
But this sucks. Any ideas on this one
jfarias
The good new: This is fixed in post Beta2 builds. The bad news: We aren't able to get this fix in the Beta2 build. The workaround is easy. You need to handle the CellMouseDown and get the cell's reference:
Dim c as DataGridViewCell = DataGridView1.Item(e.ColumnIndex, e.RowIndex)
This will keep the exception from occurring.
Thanks,
Mark
.NET Client Program Manager
Microsoft
This post is provided "as-is"
Tom Norman
where can i e mail the project to
thanks,
kapil
Max MUCCI
tom_gee
-mark
.NET Client Program Manager
Microsoft
This post is provided "as-is"
vpsivam
You're 2 for 2 Mark.
Thanks.
Green Beret
thanks,
-mark
.NET Client Program Manager
Microsoft
This post is provided "as-is"
Ma?o
BrainWasher
So, when parsing the Percentage format (P2) you need to end up with an Int16 type. In addition, when you handle this event and set the value you need to set the ParsingApplied = true. Here is what my CellParsing event looks like:
Private Sub DataGridView1_CellParsing(...) Handles DataGridView1.CellParsing
If DataGridView1.Columns(e.ColumnIndex).Name <> "UnitsInStock" Then Return
e.Value = Int16.Parse(e.Value.ToString().Replace("%", "").Trim())
e.ParsingApplied = True
End Sub
Hope this helps!
-mark
.NET Client Program Manager
Microsoft
This post is provided "as-is"
Perky
void grdTETypes_CellParsing(object sender, DataGridViewCellParsingEventArgs e)
{
if (e.DesiredType != typeof(decimal))
return;
e.Value = e.Value.ToString().Replace("%", "").Trim();
}