ScrollBar System.ArgumentException

  • Thread starter Thread starter Victor Crudu
  • Start date Start date
V

Victor Crudu

Hi,
could somebody help me to solve the follwing problem ?
I get the following exception when i set as the DataSource of a DataGrid a
DataTable.
This situation can be only if I change programaticaly the minimum property
of the scroll bar to be >0. But i even do not have access to the scroll bars
of the grid because the scrollbars are protected.

Unhandled Exception:

'0' is not a valid value for 'value'. 'value' should be between 'minimum'
and 'maximum'.

Error source: System.Windows.Forms

System.ArgumentException
Stack Trace:
at System.Windows.Forms.ScrollBar.set_Value(Int32 value)
at System.Windows.Forms.DataGrid.SetDataGridTable(DataGridTableStyle
newTable, Boolean forceColumnCreation)
at System.Windows.Forms.DataGrid.Set_ListManager(Object newDataSource,
String newDataMember, Boolean force, Boolean forceColumnCreation)
at System.Windows.Forms.DataGrid.Set_ListManager(Object newDataSource,
String newDataMember, Boolean force)
at System.Windows.Forms.DataGrid.set_DataSource(Object value)
at FastEmailSender.MainForm.RulesTree_AfterSelect(Object sender,
TreeViewEventArgs e)
at System.Windows.Forms.TreeViewEventHandler.Invoke(Object sender,
TreeViewEventArgs e)
at System.Windows.Forms.TreeView.OnAfterSelect(TreeViewEventArgs e)
at System.Windows.Forms.TreeView.TvnSelected(NMTREEVIEW* nmtv)
at System.Windows.Forms.TreeView.WmNotify(Message& m)
at System.Windows.Forms.TreeView.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
 
Hi Victor,

How exatcly do you bind the datagrid to the data source? Another question
would be whether you have customized the grid in some way?
 
Hi Dmitriy,
thanks for your help.
I simply assign the datatable to the datasource of the grid without changing
grid table styles.
One more I must say is that I bind a currency manager to datagrid as I need
it for getting and changing the Position property.

Victor.

Dmitriy Lapshin said:
Hi Victor,

How exatcly do you bind the datagrid to the data source? Another question
would be whether you have customized the grid in some way?
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Victor Crudu said:
Hi,
could somebody help me to solve the follwing problem ?
I get the following exception when i set as the DataSource of a DataGrid a
DataTable.
This situation can be only if I change programaticaly the minimum property
of the scroll bar to be >0. But i even do not have access to the scroll bars
of the grid because the scrollbars are protected.

Unhandled Exception:

'0' is not a valid value for 'value'. 'value' should be between 'minimum'
and 'maximum'.

Error source: System.Windows.Forms

System.ArgumentException
Stack Trace:
at System.Windows.Forms.ScrollBar.set_Value(Int32 value)
at System.Windows.Forms.DataGrid.SetDataGridTable(DataGridTableStyle
newTable, Boolean forceColumnCreation)
at System.Windows.Forms.DataGrid.Set_ListManager(Object newDataSource,
String newDataMember, Boolean force, Boolean forceColumnCreation)
at System.Windows.Forms.DataGrid.Set_ListManager(Object newDataSource,
String newDataMember, Boolean force)
at System.Windows.Forms.DataGrid.set_DataSource(Object value)
at FastEmailSender.MainForm.RulesTree_AfterSelect(Object sender,
TreeViewEventArgs e)
at System.Windows.Forms.TreeViewEventHandler.Invoke(Object sender,
TreeViewEventArgs e)
at System.Windows.Forms.TreeView.OnAfterSelect(TreeViewEventArgs e)
at System.Windows.Forms.TreeView.TvnSelected(NMTREEVIEW* nmtv)
at System.Windows.Forms.TreeView.WmNotify(Message& m)
at System.Windows.Forms.TreeView.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
 
Victor,

I would than suggest the following:

1. Use the SetDataBinding method to assign a table as a data source
2. You don't have to bind a currency manager. Instead, obtain a currency
manager instance for the data source (that is, your data table) and the data
member (I guess this equals to an empty string in your case) from the form's
BindingContext property.
 
Back
Top