Bug 468110

Summary: DataGridView. Crash when adding Columns
Product: [Mono] Mono: Class Libraries Reporter: Mario Carrion <mcarrion>
Component: Windows.FormsAssignee: Mono Bugs <mono-bugs>
Status: RESOLVED FIXED QA Contact: Mono Bugs <mono-bugs>
Severity: Normal    
Priority: P5 - None CC: forgotten_CRPsQFwJ3b
Version: SVN   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Beta-Customer Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Bug Depends on:    
Bug Blocks: 468504, 428870    
Attachments: Example
.NET DataGridView

Description Mario Carrion 2009-01-21 21:08:53 UTC
Created attachment 266660 [details]
Example

1. Compile attached code
2. Run
3. Crash.

Expected:

No crash, see the attached image.

In .NET you will see an empty row. The output is the following:

 mario@malakarma:~/Documents/Windows> gmcs -r:System.Windows.Forms,System.Drawing,System.Data,System Program.cs -out:FormTest.exe && mono --debug FormTest.exe 
System.ArgumentOutOfRangeException: Index is less than 0 or more than or equal to the list count.
Parameter name: index
-1
  at System.Collections.ArrayList.ThrowNewArgumentOutOfRangeException (System.String name, System.Object actual, System.String message) [0x00000] in /home/mario/repository/mcarrion/mcs/class/corlib/System.Collections/ArrayList.cs:3258 
  at System.Collections.ArrayList.get_Item (Int32 index) [0x00013] in /home/mario/repository/mcarrion/mcs/class/corlib/System.Collections/ArrayList.cs:2649 
  at System.Windows.Forms.DataGridViewRowCollection.get_Item (Int32 index) [0x00000] in /home/mario/repository/mcarrion/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCollection.cs:82 
  at System.Windows.Forms.DataGridView.OnUserAddedRow (System.Windows.Forms.DataGridViewRowEventArgs e) [0x0005f] in /home/mario/repository/mcarrion/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs:4933 
  at System.Windows.Forms.DataGridView.SetCurrentCellAddressCore (Int32 columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean validateCurrentCell, Boolean throughMouseClick) [0x00252] in /home/mario/repository/mcarrion/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs:5439 
  at System.Windows.Forms.DataGridView.MoveCurrentCell (Int32 x, Int32 y, Boolean select, Boolean isControl, Boolean isShift, Boolean scroll) [0x00014] in /home/mario/repository/mcarrion/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs:5931 
  at System.Windows.Forms.DataGridView.OnHandleCreated (System.EventArgs e) [0x00034] in /home/mario/repository/mcarrion/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs:3968 
  at System.Windows.Forms.Control.WmCreate (System.Windows.Forms.Message& m) [0x00000] in /home/mario/repository/mcarrion/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:5759 
  at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m) [0x001e4] in /home/mario/repository/mcarrion/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:5397 
  at System.Windows.Forms.DataGridView.WndProc (System.Windows.Forms.Message& m) [0x00000] in /home/mario/repository/mcarrion/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs:5507 
  at System.Windows.Forms.Control+ControlWindowTarget.OnMessage (System.Windows.Forms.Message& m) [0x00000] in /home/mario/repository/mcarrion/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:234 
  at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) [0x00000] in /home/mario/repository/mcarrion/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:215 
  at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) [0x00085] in /home/mario/repository/mcarrion/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NativeWindow.cs:242
Comment 1 Mario Carrion 2009-01-21 21:09:35 UTC
Created attachment 266661 [details]
.NET DataGridView
Comment 2 Forgotten User CRPsQFwJ3b 2009-01-23 01:37:44 UTC
Fixed in trunk in r124278 and backported to 2.4 in r124280. Additional crasher fixes I discoverd with your test case are fixed in trunk in r124279 and in 2.4 branch in r124281. Thanks for the bug report.