[英]Can I display number of row on RowHeaders in the DataGridView?
我的datagridview是從右到左。
當我使用此代碼時,數字顯示在最后一列。
當datagridview從左到右時,此代碼是正確的。
我想在DataGridView的所有RowHeader上顯示行數和圖像數;
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);
}
}
您可以使用DataGridView.RowCount屬性。
在此示例中,此屬性用於跟蹤DataGridView中的條目數
您可以在網格視圖標題中顯示文本,如下所示。
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);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.