Does C# allow you to add a String to a RowHeader in a DataGridView? If so, how is it accomplished?
I'm writing a Windows Form to displayed Customer Payment Data for the year so far.
The ColumnHeaders display January, February, March, etc... and rather than have a blank column with DateTime.Now.Year I would like to put it in the RowHeader to make it stand out from the actual payment data.
private void dtgworkingdays_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
this.FillRecordNo();
}
private void FillRecordNo()
{
for (int i = 0; i < this.dtworkingdays.Rows.Count; i++)
{
this.dtgworkingdays.Rows[i].HeaderCell.Value = (i + 1).ToString();
}
}
Also see Show row number in row header of a DataGridView.
datagridview1.Rows[0].HeaderCell.Value = "Your text";
It works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With