datagridview winform 4.0 [英] datagridview winform 4.0
本文介绍了datagridview winform 4.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在datagridview的cellpainting事件中,我有以下代码:
Hi,
In the cellpainting event of the datagridview I have this code:
private void dgvMain_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if ((e.ColumnIndex == 0) && (e.RowIndex >= 0))
{
...
}
该程序不会进入if语句,因为在填充datagridview之后,我使用:
dgvMain.Columns["ID"].Visible = false;
问题:请问解决方案是什么?
谢谢
the program does not get into the if statements because after I populate the datagridview, I use:
dgvMain.Columns["ID"].Visible = false;
Question: What is the solution please?
Thanks
推荐答案
请问如何解决?"
如果将其隐藏,则不要检查第0列-因为如果它不可见,则不会被绘制.隐藏不会重新排列列或删除它们-只是使它们对用户不可见(因此不会被绘制).
尝试使用第二列或您要特别绘制的任何列.
"What is the solution please?"
Don''t check for column 0 if you hide it - because it won''t get painted if it isn''t visible. Hidiing doesn''t re-order columns, or delete them - it just makes them invisible to the user (and thus not painted).
Try using the second column, or whichever one you do want to paint specially.
这篇关于datagridview winform 4.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文