By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,887 Members | 1,003 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,887 IT Pros & Developers. It's quick & easy.

DataGridView RowEnter not firing...

P: n/a
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...
Jan 11 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
If you have a datatable underlying the datagridview then you need to
manipulate the row in the underlying datatable

"hzgt9b" wrote:
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...
Jan 12 '08 #2

P: n/a
On Jan 11, 7:34*pm, Rich <R...@discussions.microsoft.comwrote:
If you have a datatable underlying the datagridview then you need to
manipulate the row in the underlying datatable

"hzgt9b" wrote:
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...- Hide quoted text -

- 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....
Jan 12 '08 #3

P: n/a
On Jan 11, 7:34*pm, Rich <R...@discussions.microsoft.comwrote:
If you have a datatable underlying the datagridview then you need to
manipulate the row in the underlying datatable

"hzgt9b" wrote:
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...- Hide quoted text -

- 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?
Jan 12 '08 #4

P: n/a
On Jan 12, 11:22*am, hzgt9b <celof...@gmail.comwrote:
On Jan 11, 7:34*pm, Rich <R...@discussions.microsoft.comwrote:


If you have a datatable underlying the datagridview then you need to
manipulate the row in the underlying datatable
"hzgt9b" wrote:
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...- Hide quoted text -
- 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?- 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.
Jan 13 '08 #5

P: n/a
On Sat, 12 Jan 2008 17:13:13 -0800 (PST), hzgt9b <ce******@gmail.com>
wrote:
>On Jan 12, 11:22*am, hzgt9b <celof...@gmail.comwrote:
>On Jan 11, 7:34*pm, Rich <R...@discussions.microsoft.comwrote:


If you have a datatable underlying the datagridview then you need to
manipulate the row in the underlying datatable
"hzgt9b" wrote:
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...- Hide quoted text -
- 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?- 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.
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.
Jan 13 '08 #6

P: n/a
On Jan 13, 1:48*am, Jack Jackson <jjack...@cinnovations.netwrote:
On Sat, 12 Jan 2008 17:13:13 -0800 (PST), hzgt9b <celof...@gmail.com>
wrote:


On Jan 12, 11:22*am, hzgt9b <celof...@gmail.comwrote:
On Jan 11, 7:34*pm, Rich <R...@discussions.microsoft.comwrote:
If you have a datatable underlying the datagridview then you need to
manipulate the row in the underlying datatable
"hzgt9b" wrote:
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...- Hide quoted text -
- 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?- 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.

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.
Jan 15 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.