添加文本到DataGridView的行标题 [英] Adding Text to DataGridView Row Header

查看:349
本文介绍了添加文本到DataGridView的行标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请问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();
            }
        }
 

另请参见<一href="http://stackoverflow.com/questions/9581626/show-row-number-in-row-header-of-a-datagridview">Show在一个DataGridView 的行标题行号。

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.

这篇关于添加文本到DataGridView的行标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆