2011-09-13 19 views
3

关于行标题:关于dataGridView的行列标题的问题

1)我可以在它们上面写文字吗?

2)我可以改变它们的颜色,以便它们具有与其他所有细胞不同的颜色吗?

3)我可以让这个箭头出现,当我点击他们走开?

关于栏目标题:

4)我可以更改它们的颜色吗?

在此先感谢。

+0

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.aspx所有我会告诉你是在这里,如果你点击行标题和列标题样式成员和采取环顾四周。有很多关于文档的信息 –

+0

谢谢丹尼尔,我已经玩过适当的东西,但没有运气。感谢您的链接,但除了我已经看到它,我没有在那里找到关于我的问题的答案。 – alexxx

+0

我已经解决了2)和4)问题,将EnableHeadersVisualStyles属性设置为true。关于问题1)和3)仍然需要帮助,我们将不胜感激。 – alexxx

回答

2

回答〜3)

处理的CellPainting事件:

dataGridView.CellPainting += 
    new DataGridViewCellPaintingEventHandler (dataGridView_CellPainting); 

然后该处理程序,只的ColumnIndex响应 “-1”(表示行标头):

void dataGridView_CellPainting (object sender, DataGridViewCellPaintingEventArgs e) 
{ 
    if (e.ColumnIndex == -1) 
    { 
     e.PaintBackground (e.CellBounds, true); 
     e.Handled = true; 
    } 
}