Bug 677 - [PATCH] DataGridView column header misbehavior and crash; also VirtualMode fix
Summary: [PATCH] DataGridView column header misbehavior and crash; also VirtualMode fix
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: Windows.Forms ()
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-09-08 11:54 UTC by Stephen McConnel
Modified: 2011-10-17 07:07 UTC (History)
2 users (show)

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


Attachments
The attached program was built with both Microsoft Visual Studio 2008 and MonoDevelop 2.4 using version 2.8.1 of the mono libraries. It works fine on Windows using Microsoft's .Net implementation. (9.39 KB, application/x-compressed-tar)
2011-09-08 11:54 UTC, Stephen McConnel
Details
This patch fixes the three problems described. It does not remove the mentioned [MonoTODO] marker, however.) (2.49 KB, patch)
2011-09-08 11:56 UTC, Stephen McConnel
Details
proposed patch (4.47 KB, patch)
2011-09-12 19:32 UTC, Stephen McConnel
Details
proposed patch (4.47 KB, patch)
2011-09-13 10:56 UTC, Stephen McConnel
Details
proposed patch (4.48 KB, patch)
2011-09-13 17:45 UTC, Stephen McConnel
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 Stephen McConnel 2011-09-08 11:54:30 UTC
Created attachment 264 [details]
The attached program was built with both Microsoft Visual Studio 2008 and MonoDevelop 2.4 using version 2.8.1 of the mono libraries.  It works fine on Windows using Microsoft's .Net implementation.

1) DataGridView.InvalidateCell() crashes if the provided cell is a column header.
2) DataGridView.GetCellDisplayRectangle() returns an incorrect value if the the provided cell is a column header.
3) VirtualMode is not fully implemented (there's even a [MonoTODO ("VirtualMode is not supported.")] marker on the DataGridView.VirtualMode property) possibly because DataGridView.OnCellValuePushed() is never called anywhere.

The attached sample program demonstrates these problems, although the third problem can't be seen until the first one is fixed.

The attached patch file
Comment 1 Stephen McConnel 2011-09-08 11:56:46 UTC
Created attachment 265 [details]
This patch fixes the three problems described.  It does not remove the mentioned [MonoTODO] marker, however.)
Comment 2 Stephen McConnel 2011-09-08 12:22:13 UTC
Row header cells may also have problems with DataGridView.InvalidateCell() and DataGridView.GetCellDisplayRectangle(), but the test program and the proposed patch don't touch that part of the code.
Comment 3 Stephen McConnel 2011-09-12 19:32:30 UTC
Created attachment 334 [details]
proposed patch

This updated patch should handle both column headers and row headers properly in DataGridView.InvalidateCell() and DataGridView.GetCellDisplayRectangle().
Comment 4 Stephen McConnel 2011-09-13 10:56:35 UTC
Created attachment 339 [details]
proposed patch

This third version of the proposed patch fixes a typo in an exception message introduced by the second version of the patch.
Comment 5 Stephen McConnel 2011-09-13 17:45:27 UTC
Created attachment 356 [details]
proposed patch

This fourth proposed patch fixes a bug in the row index checking introduced by the third proposed patch.  The DataGridView code likes to look at row 0 even when it doesn't exist.  This patch considers row indexes invalid only if < -1 (not a column header) or > 0 and beyond valid indexing into rows.
Comment 6 Stephen McConnel 2011-09-14 12:12:57 UTC
This bug affects both the 2.8 and 2.10 branches.
Comment 7 Tom Hindle 2011-10-17 07:07:39 UTC
nice test case :)

commit c8da57fca044c8df45d88b677a835bb97f4470f7