DatagridView assign a variable value for each cell in column
I want to assign a value for example : 000001 for each cell in a datagrid column "COD"
How can i do it ?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Bechir BejaouiPosted Mar 14, 2009, 7:34 AM
DataGridViewCell myCellTemplate = new DataGridViewTextBoxCell();
//Set the format of the cell
myCellTemplate.Style.Format = string.Format("{0}",0001);
//Set the style of the column using celltemplate attribute
dataGridView1.Columns["COD"].CellTemplate = myCellTemplate;