tags:

views:

27

answers:

3

Hello stackoverflow.

I want my (readonly,fullrowselect) datagridviews to have no selected rows when the form is loaded. I tried .ClearSelection in the forms 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.

Thanks

A: 

Try call an

yourGridView.Update(); 

after calling the

ClearSelection();

to redraw the grid.

Darkxes
doesn't work either in the constructor or the FormLoad event
francis
A: 

Does SelectAll() works ?

Jazz.
not, but i think thats because the datagridview is single selection
francis
dataGridView1.CurrentCell = null; ?
Jazz.
still the same behavior as when i do it in the FormLoad event. it's weird but its like whatever i'm trying to do to all the dgvs, it wont work only with the dgv that is in the other tab page... and i've already checked if i'm updating the datasource for that dgv with any events and such...
francis
Have you tried updating onTabChanged Event ?
Jazz.
yes, and it works but as i've said before, i don't want the selected rows to get deselected whenever the user changes tab... i want to clearSelection only as the form's "initial setup"
francis
create a bool done and mark it false after the first time :o
Jazz.