Bug 3415 - DataGridView reports no SelectedRows when rowselectionchanged
Summary: DataGridView reports no SelectedRows when rowselectionchanged
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: Windows.Forms ()
Version: 2.10.x
Hardware: Other All
: Lowest normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-02-12 22:48 UTC by Esteban
Modified: 2012-09-02 14:10 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Patch to fix problem (907 bytes, patch)
2012-06-02 09:43 UTC, Steve
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Esteban 2012-02-12 22:48:50 UTC
Description of Problem:
When the datagridview.selectionchanged method is called, sometimes the selectedrows property (which is an array of components) is empty.

Steps to reproduce the problem:
1. Create a datagridview component and give it a data source
2. inside the selectionchanged function put:
if datagridview(component).selectedrows.count>0 {
 
}


Actual Results:
the program flow will not always give a selectedrows.count>0 even when you know you have selected a row

Expected Results:
the selectedrows.count value should always be > 0 if you selected a row

How often does this happen? 
whenever you select from the first to the last (in that order) item on the list (works from the last to the first)

Additional Information:
I'm not joking
Comment 1 Steve 2012-05-30 14:46:51 UTC
I recently ran into this too.  My best idea for a workaraound didn't help either, i.e. using BeginInvoke() inside of the SelectionChanged event-handler to wait a little bit before checking the value of SelectedRows.
Comment 2 Steve 2012-06-02 09:43:37 UTC
Created attachment 2000 [details]
Patch to fix problem

Here's my patch to fix the problem.  It's currently under review on the mono-devel list, but if you can't wait, or wish to test it yourself, here you go.
Comment 3 Thomas Goldstein 2012-06-04 18:00:36 UTC
Steve's patch has been pushed (commit bcb49c60cdb9e9797fa91473955fe71828805643), so the bug is fixed.

I cannot close this bug report, though (anyone passing by who can do it, go ahead).