添加文本到DataGridView的行标题文本、标题、DataGridView

2023-09-02 01:37:16 作者:葬夏′

请问C#允许你把字符串添加到的rowHeader在一个DataGridView?如果是这样,它是如何做到的呢?

我正在写一个Windows窗体来显示客户付款数据,今年迄今。

在ColumnHeaders显示一月,二月,三月,等...而非有一个空白列与DateTime.Now.Year我希望把它放在的rowHeader,使之与实际支付数据脱颖而出。

解决方案

 私人无效dtgworkingdays_DataBindingComplete(对象发件人,DataGridViewBindingCompleteEventArgs E)
        {
            this.FillRecordNo();
        }


私人无效FillRecordNo()
        {
            的for(int i = 0; I< this.dtworkingdays.Rows.Count;我++)
            {
                this.dtgworkingdays.Rows [I] .HeaderCell.Value =第(i + 1)的ToString();
            }
        }
 

另请参见Show在一个DataGridView 的行标题行号。

Does C# allow you to add a String to a RowHeader in a DataGridView? If so, how is it accomplished?

word标题怎么添加轮廓 文本2

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.