在窗口应用程序的DataGridView中未选择任何行 [英] No row selected in DataGridView in window application

查看:70
本文介绍了在窗口应用程序的DataGridView中未选择任何行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..朋友,我在我的窗口项目中使用DataGridView时,我遇到一个问题,即在其中自动选择了一行.我使用DataGrid.ClearSelection()方法,但它仅清除当前选择并自动选择DataGridView的第一行.您能帮我解决上述问题吗?

提前感谢

Rathi

Hi.. friends I''m using DataGridView in my window project I have a problem that there is automatically a row is select in it. I use DataGrid.ClearSelection() method, but it clear the current selection only and select the first row of DataGridView automatically. Would you plz help me how to tackled the above problem.

Thnks in Advance

Rathi

推荐答案

您是否需要选定的行?如果没有,我通常通过作弊来处理此问题,只需将选定的单元格ForeColor和BackColor设置为与未选定的单元格相同的颜色即可.这样,您就永远看不到亮点.

如果要更改突出显示的内容,也可以更改选择模式...整行,整列,仅一个单元格等.ClearSelection方法可能仅在选择模式设置为CellSelect时才起作用.

希望这会有所帮助.

-我也发现了这一点:
http://manfred-ramoser.blogspot.com/2008/01/hide- selection-in-datagridview.html [ ^ ]
Do you ever need a selected row? If not, I usually handle this by cheating and just setting the selected cell ForeColor and BackColor to the same color as an unselected cell. This way you just never see the highlight.

You can also change the selection mode if you want to change what gets highlighted...the whole row, the whole column, just a cell, etc. It might be that the ClearSelection method only works if the selection mode is set to CellSelect.

Hope this helps.

--I also found this:
http://manfred-ramoser.blogspot.com/2008/01/hide-selection-in-datagridview.html[^]


这篇关于在窗口应用程序的DataGridView中未选择任何行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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