How we change datagridview header name?
I write a code in windows form application for change the header name.
DataGridViewCellStyle columnHeaderStyle = new
DataGridViewCellStyle();
columnHeaderStyle.BackColor = Color.Beige;
columnHeaderStyle.Font = new Font("Bookman Old Style", 8,
FontStyle.Bold);
dataGridView1.ColumnHeadersDefaultCellStyle = columnHeaderStyle;
dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
dataGridView1.Columns[0].HeaderText = "Item Code";
dataGridView1.Columns[1].HeaderText = "Item Name";
But when I run this code there shows a error. "Index was out of range.
Must be non-negative and less than the size of the collection.Parameter
name: index" How Can I solve it?
No comments:
Post a Comment