This article has been archived. It is offered "as is" and will no longer be updated.
When you use the SHIFT+UP ARROW key combination in a DataGrid control, a problem may occur. When this problem occurs, you also have the ReadOnly property of the DataGrid control set to true. You also have all the rows in the DataGrid control selected.
You may receive the following error message:
System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.Windows.Forms.DataGrid.ProcessGridKey(KeyEventArgs ke) at System.Windows.Forms.DataGrid.ProcessDialogKey(Keys keyData) at System.Windows.Forms.Control.PreProcessMessage(Message& msg) at System.Windows.Forms.ThreadContext.System.Windows.Forms. UnsafeNativeMethods+IMsoComponent.FPreTranslateMessage(MSG& msg)
To resolve this problem, obtain the latest service pack for the Microsoft .NET Framework 1.0. The following file is available for download from the Microsoft Download Center:
The Microsoft .NET Framework 1.0 Service Pack 3
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section. This problem was first corrected in the Microsoft .NET Framework 1.0 Service Pack 3.
Steps to reproduce the problem
Start Microsoft Visual Studio .NET.
On the File menu, point to New, and then click Project.
The New Project dialog box appears.
Under Project Types, click Visual Basic Projects.
Under Templates, click Windows Application.
In the Name box, type WindowsApplication1 as the name of the application.
By default, a file that is named Form1.vb is added to the project if you are using Visual Basic .NET.
By default, a file that is named Form1.cs is added to the project if you are using Microsoft Visual C# .NET.
Double-click DataGrid to add a DataGrid control to the form that is named Form1.
By default, the DataGrid control that is named DataGrid is added to the form that is named Form1.
In Design view of Form1, double-click the form that is named Form1, and then add the following code to the Form1_Load procedure:
Visual Basic .NET code
Dim dataTable As DataTabledataTable = New DataTable("TABLE")Dim col As New DataColumn()col.DataType = Type.GetType("System.String")col.ColumnName = "col1"col.DefaultValue = "000"'Add columns. dataTable.Columns.Add(New DataColumn("Col1"))dataTable.Columns.Add(New DataColumn("Col2"))dataTable.Columns.Add(New DataColumn("Col3"))Dim myDataRow As DataRow = dataTable.NewRow()myDataRow(0) = "11111"myDataRow(1) = "22222"myDataRow(2) = "33333"dataTable.Rows.Add(myDataRow)DataGrid1.DataSource = dataTable.DefaultView