Article

Sizeable delay when AutoSizeColumnMode is set to AllCells.

Information

 
Article Number000093743
EnvironmentProduct: OpenEdge
Version: 11.x
OS: Windows
Other: GUI for .NET
Question/Problem Description
The application includes a datagridview GUI for .NET control that loads a large number of rows into the datagridview. The number of rows was large enough that the application implemented batching to allow the user to start seeing rows, in the view, even before all rows had been loaded into the view. 

To allow all of the data in a column to be viewed, the datagridview's AutoSizeColumnMode was set to AllCells. This caused a sizable delay in data being displayed, to the point where the application appeared to be in a loop. 

Assume a datagridview as follows:
DEFINE PRIVATE VARIABLE datagridview1 AS System.Forms.DataGridView NO-UNDO.
THIS-OBJECT:datagridview1 = NEW System.Windows.Forms.DataGridView().



To set this attribute the following code might be used:
datagridview1:AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode:AllCells.



 
Steps to Reproduce
Clarifying Information
Application was performing well until the AutoSizeColumnMode attribute was set to AllCells.
Error Message
Defect/Enhancement Number
Cause
This is expected behavior.
DataGridViewAutoSizeColumnsMode.AllCells, directs .NET to adjust the widget of all cells in the column. If a very large number of rows has been loaded into the control, this could take a long time to execute.
Resolution
Replace DataGridViewAutoSizeColumnsMode.AllCells with DataGridViewAutoSizeColumnsMode.DisplayedCells. DisplayedCells adjusts the widths of cells that are in rows currently displayed on the screen.
Workaround
Notes
To use the value DataGridViewAutoSizeColumnsMode:AllCells or any other of the values associated with DataGridViewAutoSizeColumnsMode, USING System.Windows.Forms.*. must be included in the application code.

References to other Documentation:

DataGridView.AutoSizeColumnsMode Property:
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.datagridview.autosizecolumnsmode?view=netframework-4.7.2

DataGridViewAutoSizeColumnsMode ENUM:
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.datagridviewautosizecolumnsmode?view=netframework-4.7.2
Attachment 
Last Modified Date1/10/2019 4:02 PM


Feedback
 
Did this article resolve your question/issue?

   

Your feedback is appreciated.

Please tell us how we can make this article more useful. Please provide us a way to contact you, should we need clarification on the feedback provided or if you need further assistance.

Characters Remaining: 1025