开发者

Trouble with Datagridview.ClearSelection()

开发者 https://www.devze.com 2023-01-22 09:11 出处:网络
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 do

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

精彩评论

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

关注公众号