DataGridView RowEnter not firing...

H

hzgt9b

Using VS2005, VB.NET,
I have a windows app with a DataGridView (lets call it DGV). At some
point in the life of my app I want to clear the selection of the
currently selected row (Multiselect=false) from DGV - to do that I
tried this:
DGV.ClearSelection()

Cosmetically this appears to work but it appears that the DGV still
stores the index value of the selected row. If the 1st row I click on
after executing ClearSelection() is the row that was previously
selected then the RowEnter event is NOT triggered - clicking on any
other row than the previously selected row DOES trigger the RowEnter
event.

Is this a bug and/or is there some (other) way for me to clear the
selection of current row from a DGV?

Any help would be appreciated...
 
R

Rich

If you have a datatable underlying the datagridview then you need to
manipulate the row in the underlying datatable
 
H

hzgt9b

If you have a datatable underlying the datagridview then you need to
manipulate the row in the underlying datatable








- Show quoted text -

My DataGridView's DataSource is an in memory DataTable. Regardless it
is the DataGridView control that is not responding to a click on a row
that was selected just prior to calling the DataGridView's
ClearSelection() method - it seems that this would be independent of
any underlying data....
 
H

hzgt9b

If you have a datatable underlying the datagridview then you need to
manipulate the row in the underlying datatable








- Show quoted text -

Rich,
I mis-read your message - please ignore my previous response.

Ok, so I changed the code to be this:

Me.dgvCases.CurrentRow.Selected = False
Me.dgvCases.ClearSelection()

But the problem persists. After this code runs - no rows in the DGV
are highlighted but the DGV's record selector (little triange) still
points to the previously selected row & I get the same result as
before.

Is there another setting in the "row in the underlying datatable" that
I need to manipulate?
 
H

hzgt9b

Rich,
I mis-read your message - please ignore my previous response.

Ok, so I changed the code to be this:

            Me.dgvCases.CurrentRow.Selected = False
            Me.dgvCases.ClearSelection()

But the problem persists. After this code runs - no rows in the DGV
are highlighted but the DGV's record selector (little triange) still
points to the previously selected row & I get the same result as
before.

Is there another setting in the "row in the underlying datatable" that
I need to manipulate?- Hide quoted text -

- Show quoted text -

I finally figured this out... instead of setting the CurrentRow to not
be selected, I set CurrentCell=Nothing to get the behavior I was
looking for. I no longer needed to call ClearSelection() call. Here's
the code that worked for me:

Me.dgvCases.CurrentCell = Nothing

Thanks to those that responded.
 
J

Jack Jackson

I finally figured this out... instead of setting the CurrentRow to not
be selected, I set CurrentCell=Nothing to get the behavior I was
looking for. I no longer needed to call ClearSelection() call. Here's
the code that worked for me:

Me.dgvCases.CurrentCell = Nothing

Thanks to those that responded.

I have been struggling with this same issue, and have discovered that
setting CurrentCell = Nothing does not prevent a row from being
selected if it is done before the first Paint event. It appears that
the DataGridView selects the first row when it is first painted.
 
H

hzgt9b

I have been struggling with this same issue, and have discovered that
setting CurrentCell = Nothing does not prevent a row from being
selected if it is done before the first Paint event.  It appears that
the DataGridView selects the first row when it is first painted.- Hide quoted text -

- Show quoted text -

Yea, I've read similar things. Fortunately for me, my call to set the
DataGridView's CurrentCell = Nothing is long after the control is
initially painted so I did not run into this issue. Best of luck and
thanks again for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top