Microsoft KB Archive/828076

= FIX: The DataGrid control scrolls unexpectedly when you use the arrow keys to move in Visual Studio .NET 2003 =

Article ID: 828076

Article Last Modified on 4/7/2006

-

APPLIES TO


 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Academic Edition

-





SYMPTOMS
In Microsoft Visual Studio .NET 2003, when you work with a DataGrid control that has wide cells and a horizontal scroll bar, you may see unusual horizontal scrolling behavior if you use the arrow keys to move from cell to cell.



CAUSE
This problem occurs if the DataGrid control has a horizontal scroll bar and the DataGrid control contains a wide column. If a cell in the wide column has focus, and a part of the cell is located outside the viewing area of the DataGrid control, the DataGrid control scrolls to the left when you press the UP ARROW key or the DOWN ARROW key. When this problem occurs, one column scrolls out of the viewing area. This behavior continues until the whole wide cell is visible or until no more columns exist to the left of the cell.



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 Microsoft .NET Framework 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 05-Sep-2003 14:08  1.1.4322.941  1,703,936  Fl_system_design.dll 05-Sep-2003 14:08  1.1.4322.941    466,944  Fl_system_drawing.dll 05-Sep-2003 14:09  1.1.4322.941  2,039,808  Fl_system_windows_forms.dll



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.



WORKAROUND
To work around this problem, extend the System.Windows.Forms.DataGrid class, and then create a ScrollEventArgs object when the current cell changes: private void myGrid_CurrentCellChanged(object sender, EventArgs e) { //Get the horizontal scroll bar. HScrollBar horizScrollBar = this.HorizScrollBar as HScrollBar;

//The DataGridTableStyle provides the width of each column. DataGridTableStyle dgts = this.TableStyles[0];

//Set the initial value of the width. int width = 0; //If the current cell is completely visible, abort. if (width < horizScrollBar.Value) {       return; }

//Loop and compute the previous width to the current cell. width = 0; for (int i = 0; i < this.CurrentCell.ColumnNumber; i++) {       width += dgts.GridColumnStyles[i].Width; }

//Create a new scroll event to postion the cell at the left edge. ScrollEventArgs se = new ScrollEventArgs(ScrollEventType.LargeIncrement, width);

//Scroll the grid. this.GridHScrolled(this, se); }

