In the form initiator code, add some rows, and hide some:
public Form1() { InitializeComponent(); dataGridView1.Rows.Add("A1"); dataGridView1.Rows.Add("A2"); dataGridView1.Rows.Add("A3");// dataGridView1.Rows.Add("b1");// dataGridView1.Rows.Add("b2");// dataGridView1.Rows.Add("b3");// dataGridView1.Rows.Add("c1");// dataGridView1.Rows.Add("c2"); dataGridView1.Rows[0].Visible = false; dataGridView1.Rows[1].Visible = false;// dataGridView1.Rows[2].Visible = false;// dataGridView1.Rows[7].Visible = false;// dataGridView1.Rows[6].Visible = false; }
Now, run the program, and sort the column a few times.
I get:
An unhandled exception of type 'System.StackOverflowException' occurred in System.Windows.Forms.dll
The call stack looks like this (the last row repeats for ever, as you'd expect with a stack overflow exception)System.Windows.Forms.dll!System.Windows.Forms.PropertyStore.LocateObjectEntry(short entryKey = 92, out int index = 0) + 0x1d bytes
System.Windows.Forms.dll!System.Windows.Forms.PropertyStore.GetObject(int key, out bool found = false) + 0x37 bytes
System.Windows.Forms.dll!System.Windows.Forms.DataGridViewRow.AccessibilityObject.get() + 0x3a bytes
System.Windows.Forms.dll!System.Windows.Forms.DataGridView.DataGridViewAccessibleObject.GetChild(int index) + 0xa3 bytes
System.Windows.Forms.dll!System.Windows.Forms.DataGridViewRow.DataGridViewRowAccessibleObject.Bounds.get() + 0x16f bytes
System.Windows.Forms.dll!System.Windows.Forms.DataGridViewRow.DataGridViewRowAccessibleObject.Bounds.get() + 0x179 bytes
System.Windows.Forms.dll!System.Windows.Forms.DataGridViewRow.DataGridViewRowAccessibleObject.Bounds.get() + 0x179 bytes
I am seeing this error occasionally in real code that I'm trying to make work - this sample is deliberately small to make sure that it's clear that I'm not doing anything special.
Has anyone else encountered this issue, and is there a solution? I've searched as many places as I can think of, but not yet found a solution.
Alun.
~~~~