Kbase P144322: Cannot access .NET DataGridView columns in ABL
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  3/21/2011 |
|
Status: Verified
SYMPTOM(s):
Cannot access .NET DataGridView columns in ABL
Lead attributes in a chained-attribute expression (a:b:c) must be type HANDLE or a user-defined type and valid (not UNKNOWN). (10068)
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
FACT(s) (Environment):
Attempting to reference column as a subscripted item of the Columns property, e.g. rCustGrid:Columns[2]:Width.
Procedure was not generated using Visual Designer.
DataGridView is bound to ProBindingSource.
Columns are not added with the Add or AddRange methods.
AutoGenerateColumns property of DataGridView is True.
Windows
OpenEdge 10.2A
CAUSE:
The DataGridView.DataSource is bound to the ProBindingSource before the DataGridView has been added to their parent form. Because of this, columns are not generated in the Columns collection for the fields in the ProBindingSource. Errors occur when an attempt is made to reference a column which does not exist.
FIX:
If DataGridView.AutoGenerateColumns is True, assign the DataSource property of the DataGridView after the DataGridView has been added to the Controls property of the parent form.
For example, the following sequence WILL NOT cause columns to be generated, and the last statement will cause an error:
rCustGrid:DataSource = rBindS.
controls = rMainForm:Controls.
controls:Add(rCustGrid).
rCustGrid:Columns[1]:Width = 5.
However, this sequence WILL cause columns to be generated, and the last statement will execute successfully:
controls = rMainForm:Controls.
controls:Add(rCustGrid).
rCustGrid:DataSource = rBindS.
rCustGrid:Columns[1]:Width = 5.