Microsoft KB Archive/828347

= &quot;System.ArgumentException: '0' is not a valid value for 'value'&quot; Error Message in a Windows Forms Application =

Article ID: 828347

Article Last Modified on 10/25/2005

-

APPLIES TO


 * Microsoft .NET Framework 1.0 Service Pack 2

-



SYMPTOMS
If you populate a DataGrid control while a Microsoft Windows Form is minimized, you may receive the following exception error message:

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

Note Not all circumstances that produce this error are known.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



RESOLUTION
A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next .NET Framework 1.0 service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The English version of this hotfix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.   Date         Time   Version       Size       File name                 Platform ---  03-Sep-2003  14:00  1.0.3705.454  1,179,648  System.data.dll           x86 03-Sep-2003 14:01  1.0.3705.454  1,695,744  System.design.dll         x86 03-Sep-2003 14:01  1.0.3705.454  1,994,752  System.windows.forms.dll  x86 02-Sep-2003 23:06                   16,672  System.windows.forms.ldo 02-Sep-2003 23:01  1.0.3705.454     57,344  System.windows.forms.tlb



Steps to Reproduce the Behavior
 In Microsoft Visual Studio .NET, create a new Visual Basic .NET Windows application. By default, Form1 is created. Add a Label control (Label1), a Command Button control (Command1), and a Panel control (Panel1) to Form1. Add a DataGrid control (DataGrid1) to the Panel control.  Add the following code to Form1: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i As Integer Dim ds As DataSet Dim myTable As DataTable

Me.Panel1.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ Or System.Windows.Forms.AnchorStyles.Left) _           Or System.Windows.Forms.AnchorStyles.Right) Me.Panel1.Location = New System.Drawing.Point(8, 48)

' Use the following MakeTable function to create a new table. myTable = MakeNamesTable

For i = 1 To 1000 ds = New DataSet ds.Tables.Add(myTable) DataGrid1.DataSource = ds.Tables(0).DefaultView Application.DoEvents Label1.Text = (CStr(i) & &quot; / 1000&quot;) DataGrid1.Width = (Panel1.Left + Panel1.Width) - 20 ds.Tables.Remove(myTable) Next i       MsgBox(&quot;Finished processing.  You must minimize the form before this point.&quot;) ds.Dispose End Sub

Private Function MakeNamesTable As DataTable 'Create a DataTable and add two columns to it. Dim namesTable As DataTable = New DataTable(&quot;Names&quot;) Dim fNameColumn As DataColumn = New DataColumn Dim lNameColumn As DataColumn = New DataColumn fNameColumn.DataType = System.Type.GetType(&quot;System.String&quot;) fNameColumn.ColumnName = &quot;Fname&quot; 'fNameColumn.DefaultValue = &quot;Fname&quot; namesTable.Columns.Add(fNameColumn) lNameColumn.DataType = System.Type.GetType(&quot;System.String&quot;) lNameColumn.ColumnName = &quot;LName&quot; namesTable.Columns.Add(lNameColumn)

'Add a row to the table. Dim myRow As DataRow myRow = namesTable.NewRow myRow(&quot;fName&quot;) = &quot;John&quot; myRow(&quot;lName&quot;) = &quot;Smith&quot; namesTable.Rows.Add(myRow)

' Return the new DataTable. MakeNamesTable = namesTable End Function  Run the application, and then click Button1. While the process is running, click the Minimize button that appears in the control box to minimize the form.</ol>

Keywords: kberrmsg kbbug kbfix kbqfe kbnetframe100presp3fix kbhotfixserver KB828347

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.