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

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

问题描述

C# 是否允许您向 DataGridView 中的 RowHeader 添加字符串?如果是这样,它是如何实现的?

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

我正在编写一个 Windows 窗体来显示今年迄今为止的客户付款数据.

I'm writing a Windows Form to displayed Customer Payment Data for the year so far.

ColumnHeaders 显示 1 月、2 月、3 月等......而不是一个带有 DateTime.Now.Year 的空白列,我想将它放在 RowHeader 中,使其从实际支付数据中脱颖而出.

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

另见 在 DataGridView 的行标题中显示行号.

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

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