DataGridView in C# -


i using datagridview display data in application.
data in table gets changed dynamically according users input.
able retrieve data according user.

i have add column named id , fill in values serially starting 1 number of rows generated dynamically.

i had added column using dgrid.columns.add("uid");

but how insert values @ runtime?

seeing code, not correct do:

dgrid.columns.add("uid"); 

you have do:

dgrid.columns.add("uidcolumn", "uid"); 

to modify/add value of existing cell, if row exists, can do:

dgrid.rows[0].cells["uidcolumn"].value = myvalue; 

that modify value of column name uidcolumn , row 0. according problem, have is:

for (int = 0; < dgrid.rows.count; i++) {     dgrid.rows[i].cells["uidcolumn"].value = getvalueofrow(i); } 

supposing have method getvalueofrow receives row index , returns value need in id column in row.


Comments