Bug 341 - GetCellDisplayRectangle(-1,...) throws ArgumentOutOfRangeException
Summary: GetCellDisplayRectangle(-1,...) throws ArgumentOutOfRangeException
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: Windows.Forms ()
Version: unspecified
Hardware: All All
: Lowest normal
Target Milestone: Community
Assignee: Bugzilla
Depends on:
Reported: 2011-08-19 16:29 UTC by expebition
Modified: 2017-09-01 11:56 UTC (History)
2 users (show)

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

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 for Bug 341 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description expebition 2011-08-19 16:29:24 UTC
Description of Problem: An attempt to retrieve the rectangle for row headers in a DataGridView object fails.  The Microsoft documentation:


does not specify what a column of -1 means (elsewhere in .NET it refers to the row header) but it does say that it throws ArgumentOutOfRangeException if "columnIndex is less than -1 or ...", so it does indicate that a columnIndex of -1 is valid.

However, Mono throws an exception on GetCellDisplayRectangle(-1, -1, false):

public Rectangle GetCellDisplayRectangle (int columnIndex, int rowIndex, bool cutOverflow) {
    if (columnIndex < 0 || columnIndex >= columns.Count) {
        throw new ArgumentOutOfRangeException("Column index is out of range.");
    int x = 0, y = 0, w = 0, h = 0;

Steps to reproduce the problem:
1. call GetCellDisplayRectangle(-1, -1, false) on a DataGridView object

Actual Results:

Expected Results:
returns a rectangle representing the intersection of the header row and the header column

How often does this happen? 

Additional Information:
Comment 1 expebition 2011-08-19 16:45:45 UTC
I forgot to point out that GetCellDisplayRectangle(-1, -1, false) works as expected under .NET.