my datagridview is right to left.
when i use this code , numbers show on last column.
when datagridview is left to right this code is correct.
I want to display number of row and image on all RowHeader of DataGridView;
private void DataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
using (SolidBrush b = new SolidBrush(DataGridView1.RowHeadersDefaultCellStyle.ForeColor))
{
e.Graphics.DrawString(e.RowIndex.ToString(), e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);
}
}
You can use the DataGridView.RowCount Property.
In this example, this property is used to track the number of entries in a DataGridView
You can display Text in grid view header like following.
private void dataGridView_RowValidated(object sender, DataGridViewCellEventArgs e)
{
DataGridView gridView = sender as DataGridView;
if (gridview !=null)
{
gridView.Rows[0].HeaderCell.Value = string.format("Total Number of Rows: {0}",gridview .Rows.Count);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.