开发者

Trouble with Datagridview.ClearSelection()

I want my (readonly,fullrowselect) datagridviews to have no selected rows when the form is loaded. I tried .ClearSelection in the f开发者_C百科orms constructor after setting their datasource but it doesn't work (i would really like to know why...).

Then i tried in the Form_load event but it won't clear the selection on the datagridviews i have placed on the not immediately visible tab containers.

Am i doing something wrong? I could do it in the Layout event of each tab page but then it will deselect the rows every time the user changes tab, which is not a desired behavior.


I found out that it's not working in FormLoad but works fine in FormShown. So you only have to set your dataGridView1.ClearSelection in your FormShown and everything works fine.


Try call an

yourGridView.Update(); 

after calling the

ClearSelection();

to redraw the grid.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜