Datagridview scrolling bug? due to invisible row's height adjust

G

Guest

I have a datagridview, setting its datasource to a dataview which is over an
datatable in memory. no filtering rules applied on dataview/datatable.

AutoGenerateColumns = false;
AllowUserToAddRows = false;
EditMode = DataGridViewEditMode.EditProgrammatically;
MultiSelect = false;
AutoSize = true;
SelectionMode = DataGridViewSelectionMode.FullRowSelect;
RowHeadersVisible = false;
AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;
AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
ColumnHeadersHeightSizeMode =
DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False;
DefaultCellStyle.WrapMode = DataGridViewTriState.True;
RowsDefaultCellStyle.WrapMode = DataGridViewTriState.True;

The problem is:
Assume displaying area can display 10 rows, and I having 30 rows, row 10 has
a cell value which is too long and will be wrapped. this row's height will be
bigger than normal. I select this row, then scroll further down until this
row scroll up till invisible. Now click a button to edit the corresponding
value of that cell in the datatable such that it is short and no more
wordwrap. Since AutoSizeRowsMode applies to all cells, the row contain that
cell will be updated with a smaller height. Then scroll up till top,
Exception comes out:

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentOutOfRangeException: Index was out of range. Must be
non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.ArrayList.get_Item(Int32 index)
at System.Windows.Forms.DataGridViewRowCollection.SharedRow(Int32 rowIndex)
at System.Windows.Forms.DataGridView.ScrollRowsByHeight(Int32 height)
at System.Windows.Forms.DataGridView.set_VerticalOffset(Int32 value)
at System.Windows.Forms.DataGridView.DataGridViewVScrolled(Object sender,
ScrollEventArgs se)
at System.Windows.Forms.ScrollBar.OnScroll(ScrollEventArgs se)
at System.Windows.Forms.ScrollBar.DoScroll(ScrollEventType type)
at System.Windows.Forms.ScrollBar.WmReflectScroll(Message& m)
at System.Windows.Forms.ScrollBar.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
.....


Now try to resize the datagrid , then this problem disappears.
Looks like when a row's height is adjusted while it is not displayed, the
scrollbar value is not updated. Feel like a bug. Any idea? Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top