Binding Datagrid Exception

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Very Random. Can't seem to reproduce.
But sometimes when I bind my dataset to my datagrid I get the following exception:

************** Exception Text **************
System.ArgumentException: '0' is not a valid value for 'value'. 'value' should be between 'minimum' and 'maximum'.
at System.Windows.Forms.ScrollBar.set_Value(Int32 value)
....

I've tried to set the currencyManager.Position = 0 before binding. No Luck
(I've also tried not to set the currencyManager.Position to 0 and still same error)
Has anybody come accross this? or know how to fix/reproduce it?
I'm puzzled.
 
Hi Keith,

This exception is probably happened when filling value into the Value
property of a scrollbar or its derived control. this error is probably
related to the value in the data source, if the value set to the scrollbar
is 0 which is below your minmum setting in the scrollbar control. It will
thrown this exception.

If you have the complete call stack of this exception, please post it so
that we can get more information of this issue.

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
I have seen this happen when rebinding the grid while it is scrolled
to the right. Don't remember all the details but we solved it by
calling SetDataBinding(Nothing, Nothing) before rebinding the grid

I had a very simple sample that reproduced this, but unfortunately
I can't find it know

/claes


KeithH said:
Very Random. Can't seem to reproduce.
But sometimes when I bind my dataset to my datagrid I get the following exception:

************** Exception Text **************
System.ArgumentException: '0' is not a valid value for 'value'. 'value'
should be between 'minimum' and 'maximum'.
 
What you said I understand. But how does a value in the datasource relate to the scrollbar? I don't have any databindings to a scrollbar. I don't have a scrollbar control (unless you mean the form contains a scrollbar control). Plus like I said, it's random. So the user must be doing something different to set this up.

Bellow is the rest of the stacktrace. I didn't include it before because it just traces back to when I set the datasource of my database.
Notes:
c:\projects\csnet\commoncontrolscsharp\ucsgrid.cs:line 113 // this is my datagrid with this line sets the datasource property.

************** Exception Text **************
System.ArgumentException: '0' is not a valid value for 'value'. 'value' should be between 'minimum' and 'maximum'.
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 commonControlsCSharp.SGrid.PopulateSGrid(DataSet dsData, String strMapName, Boolean bAllowNew, Boolean bAllowDelete) in c:\projects\csnet\commoncontrolscsharp\ucsgrid.cs:line 113
at Delivery.PrintLabel.btnSearch_Click(Object sender, EventArgs e) in c:\projects\csnet\delivery\printlabel.cs:line 642
at Delivery.PrintLabel.txtDocket_KeyPress(Object sender, KeyPressEventArgs e) in c:\projects\csnet\delivery\printlabel.cs:line 1045
at System.Windows.Forms.KeyPressEventHandler.Invoke(Object sender, KeyPressEventArgs e)
at System.Windows.Forms.Control.OnKeyPress(KeyPressEventArgs e)
at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
at System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
at System.Windows.Forms.Control.WmKeyChar(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
at System.Windows.Forms.TextBox.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)


--
KeithH


"Ying-Shen Yu[MSFT]" said:
Hi Keith,

This exception is probably happened when filling value into the Value
property of a scrollbar or its derived control. this error is probably
related to the value in the data source, if the value set to the scrollbar
is 0 which is below your minmum setting in the scrollbar control. It will
thrown this exception.

If you have the complete call stack of this exception, please post it so
that we can get more information of this issue.

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
Hi Keith,
Thanks for the detail info, looking on the call stack information, I
suspect this issue is related to the following datagrid issue described in
the KB article below:

<"System.ArgumentException: '0' is not a valid value for 'value'" error
message when you populate a DataGrid control in a Windows Forms application>
http://support.microsoft.com/?id=838087

Please read the article and decide if you want to try this fix. To get the
fix, you may follow the instructions in the article, or please send email
to (remove "online." from this no Spam email address):
mailto:[email protected] with the following information,

* Put "HotFix Request" in the subject line
* Issue ID : 23768297
*KB Article Number : Q838087
* e-mail address
*First Name, Last Name
*MSDN Subscriber ID
*Phone Number
*Company Name (if any)

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
No Problem, I'll keep monitoring this thread,
if you have any updates please feel free to follow up this thread.

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
Back
Top