Click here to Skip to main content
15,905,323 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
i'm using visual c# 2008
i've set up a datagridview containing 2 columns with the designer.
when i run the program DataGridView.Rows.Add() pops up an error saying (translated)
"before adding a row you have to add colums to the row"
I've done some projects before populating datagridview manually and never came up with this
error.
Any ideas ?
Posted

The exception means exactly what it says. You are attempting to add rows to a table that has no columns. Have a look here to see an example what you will need.
 
Share this answer
 
v2
Comments
fheyn 24-Dec-13 13:29pm    
thanks for the response
i think the problem is mixed-up dotnet versions.
i have this code :
enum DI { INDEX=14}
double xmplfunc(DI index) { return(data[(int)index]); }
this was ok. right now the (int)-cast pops up an error message.

i had to install c#2008 on a new harddisk with already installed wxp plus dotnet3.5.
also installed with c# is dotnet2.0 (not very clever by the ms-folks)
that's the only explanation i have for the programs running before right now yielding errors.
check by debugging before you add the row that if the columns exists in datagridview.
 
Share this answer
 
Comments
fheyn 25-Dec-13 15:08pm    
thanks for the hint

instead of datagridview.rows.clear() i had datagridview.columns.clear()
everything's working fine

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900