在Datagridview上调整Rowheader属性 [英] Adjusting Rowheader properties on Datagridview
本文介绍了在Datagridview上调整Rowheader属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Winforms DataGridView中,我应该如何:
In Winforms DataGridView, how do I:
- 删除行标题上的箭头?我需要显示行标题文本,所以不能简单地设置
RowHeadersVisible = false
。 - 调整行的宽度头以编程方式?我通过代码设置行标题,因此我需要调整宽度以显示更改后的行标题文本。
推荐答案
首先重写名为DataGridView的功能
First of all override the function the DataGridView known as
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
e.PaintHeader(DataGridViewPaintParts.All & ~DataGridViewPaintParts.ContentBackground);
}
在按钮上单击将值添加到行标题
On button click add value to row header
private void button1_Click(object sender, EventArgs e)
{
string a = "khan yousafzai";
dataGridView1.RowHeadersWidth = dataGridView1.RowHeadersWidth +(7* a.Length);
dataGridView1.Rows[0].HeaderCell.Value = a;
dataGridView2.Rows.Add();
}
这篇关于在Datagridview上调整Rowheader属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文