Bug 821 - DataGridViewRowCollection.Insert() changes data element type
Summary: DataGridViewRowCollection.Insert() changes data element type
Alias: None
Product: Class Libraries
Classification: Mono
Component: Windows.Forms ()
Version: 2.10.x
Hardware: Other All
: Lowest normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2011-09-14 16:48 UTC by expebition
Modified: 2012-09-02 15:12 UTC (History)
4 users (show)

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

.NET (top) vs. Mono (bottom) on Windows (15.46 KB, image/png)
2011-09-14 16:48 UTC, expebition
Test case (20.17 KB, application/zip)
2011-11-25 18:30 UTC, Thomas Goldstein

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:

Description expebition 2011-09-14 16:48:41 UTC
Created attachment 370 [details]
.NET (top) vs. Mono (bottom) on Windows

Description of Problem:

DataGridViewRowCollection.Insert() changes the type of data element from DataGridViewCheckBoxCell to DataGridViewTextBoxCell.  DataGridViewRowCollection.Add() does not do this.  See attached for the output of the code below.

Steps to reproduce the problem:
1. create a new Visual Studio project
2. drag a DataGridView object onto the form
3. replace the dataGridView1 code with:

            // dataGridView1
            this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.dataGridView1.Location = new System.Drawing.Point(0, 0);
            this.dataGridView1.Name = "dataGridView1";
            this.dataGridView1.Size = new System.Drawing.Size(284, 262);
            this.dataGridView1.TabIndex = 0;
            this.dataGridView1.Rows.Add(new object[] { false, "one", 12 });
            this.dataGridView1.Rows.Insert(0, new object[] { false, "zero", 18 });
4. build with Visual Studio
5. run under Mono for Windows

Actual Results:

The upper-left cell is of type DataGridViewTextBoxCell and displays "False".

Expected Results:

The upper-left cell should be a checkbox (DataGridViewCheckBoxCell).

How often does this happen? 

Comment 1 Thomas Goldstein 2011-11-25 18:30:23 UTC
Created attachment 949 [details]
Test case

Above instructions do not work, because the code for Columns1, 2 and 3 is missing. Please attach self-contained test cases next times.
Comment 2 Thomas Goldstein 2011-11-25 18:51:18 UTC
Patch seems simple. In DataGridViewRowCollection.cs, in the Insert (int rowIndex, params object[] values) method,

DataGridViewRow row = new DataGridViewRow ();

DataGridViewRow row = dataGridView.RowTemplateFull;
Comment 3 Thomas Goldstein 2011-11-28 14:02:19 UTC
Patch and unit test committed (a1bf1b7be652256cdb2ae4c18d050e97908a9c18 and 666480659861b7ffe3d461652502c44bb55668a4). I don't have the needed rights to mark this bug as resolved / fixed, though.

Thanks for the report.