Kbase P147177: How to make a simple query using Visual Designer and new UI
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  9/28/2009 |
|
Status: Unverified
GOAL:
How to make a simple query using Visual Designer and new UI
GOAL:
Simple query using new UI
GOAL:
How to bind visual .net objects to Progress data using the new UI
GOAL:
Simple program to query data using Microsoft .net grid control and new UI
GOAL:
How to use probinding in in the new UI
FACT(s) (Environment):
Windows
OpenEdge 10.2x
FIX:
This simple application bellow, shows how to bind a query to visual component. This code is developed under the new UI, so it can be visually parsed within the OpenEdge Architect. In order to use it:
1 - Create a Project
2 - Connect to a sports database
3 - Create a class name ProbindingQuery and copy this source to its contents.
The key part of the code is the load method, where the probinding1 object sets its handle as the query handle, and create the tie from ABL data to .NET. Also is important to verify the names of the probinding schema. They match exactly the names of the database table and fields.
/*------------------------------------------------------------------------
File : ProbindingQuery
Purpose :
Syntax :
Description :
Author(s) : cpacheco
Created : Fri May 29 09:27:56 EDT 2009
Notes :
----------------------------------------------------------------------*/
USING Progress.Lang.*.
USING Progress.Windows.Form.
CLASS ProbindingQuery INHERITS Form :
DEFINE PRIVATE VARIABLE components AS System.ComponentModel.IContainer.
DEFINE PRIVATE VARIABLE bindingSource1 AS Progress.Data.BindingSource NO-UNDO.
DEFINE PRIVATE VARIABLE dataGridView1 AS System.Windows.Forms.DataGridView NO-UNDO.
DEFINE PRIVATE VARIABLE custNumDataGridViewTextBoxColumn AS System.Windows.Forms.DataGridViewTextBoxColumn NO-UNDO.
DEFINE PRIVATE VARIABLE nameDataGridViewTextBoxColumn AS System.Windows.Forms.DataGridViewTextBoxColumn NO-UNDO.
DEFINE PRIVATE VARIABLE addressDataGridViewTextBoxColumn AS System.Windows.Forms.DataGridViewTextBoxColumn NO-UNDO.
DEFINE PRIVATE VARIABLE city AS System.Windows.Forms.DataGridViewTextBoxColumn NO-UNDO.
Define query q for Customer scrolling.
CONSTRUCTOR PUBLIC ProbindingQuery ( ):
SUPER().
InitializeComponent().
CATCH e AS Progress.Lang.Error:
UNDO, THROW e.
END CATCH.
END CONSTRUCTOR.
/*------------------------------------------------------------------------------
Purpose:
Notes:
------------------------------------------------------------------------------*/
@VisualDesigner.
METHOD PRIVATE VOID dataGridView1_CellContentClick( INPUT sender AS System.Object, INPUT e AS System.Windows.Forms.DataGridViewCellEventArgs ):
RETURN.
END METHOD.
METHOD PRIVATE VOID InitializeComponent( ):
/* NOTE: The following method is generated by the OpenEdge Advanced GUI Visual Designer.
We strongly suggest that the contents of this method only be modified using the
Visual Designer to avoid any incompatible modifications.
&.nbsp;
Modifying the contents of this method using a code editor will invalidate any support for this file. */
@VisualDesigner.FormMember (NeedsInitialize="true").
DEFINE VARIABLE tableDesc1 AS Progress.Data.TableDesc NO-UNDO.
tableDesc1 = NEW Progress.Data.TableDesc("Customer").
THIS-OBJECT:bindingSource1 = NEW Progress.Data.BindingSource().
THIS-OBJECT:dataGridView1 = NEW System.Windows.Forms.DataGridView().
THIS-OBJECT:custNumDataGridViewTextBoxColumn = NEW System.Windows.Forms.DataGridViewTextBoxColumn().
THIS-OBJECT:nameDataGridViewTextBoxColumn = NEW System.Windows.Forms.DataGridViewTextBoxColumn().
THIS-OBJECT:addressDataGridViewTextBoxColumn = NEW System.Windows.Forms.DataGridViewTextBoxColumn().
THIS-OBJECT:city = NEW System.Windows.Forms.DataGridViewTextBoxColumn().
CAST(THIS-OBJECT:bindingSource1, System.ComponentModel.ISupportInitialize):BeginInit().
CAST(THIS-OBJECT:dataGridView1, System.ComponentModel.ISupportInitialize):BeginInit().
THIS-OBJECT:SuspendLayout().
/* */
/* bindingSource1 */
/* */
tableDesc1:ChildTables = ?.
@VisualDesigner.FormMember (NeedsInitialize="false", InitializeArray="true").
DEFINE VARIABLE arrayvar0 AS Progress.Data.ColumnPropDesc EXTENT 4 NO-UNDO.
arrayvar0[1] = NEW Progress.Data.ColumnPropDesc("cust-Num", "cust-Num", Progress.Data.DataType:INTEGER).
arrayvar0[2] = NEW Progress.Data.ColumnPropDesc("Name", "Name", Progress.Data.DataType:CHARACTER).
arrayvar0[3] = NEW Progress.Data.ColumnPropDesc("Address", "Address", Progress.Data.DataType:CHARACTER).
arrayvar0[4] = NEW Progress.Data.ColumnPropDesc("city", "city", Progress.Data.DataType:CHARACTER).
tableDesc1:Columns = arrayvar0.
THIS-OBJECT:bindingSource1:TableSchema = tableDesc1.
/* */
/* dataGridView1 */
/* */
THIS-OBJECT:dataGridView1:AutoGenerateColumns = FALSE.
THIS-OBJECT:dataGridView1:ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode:AutoSize.
@VisualDesigner.FormMember (NeedsInitialize="false", InitializeArray="true").
DEFINE VARIABLE arrayvar1 AS System.Windows.Forms.DataGridViewColumn EXTENT 4 NO-UNDO.
arrayvar1[1] = THIS-OBJECT:custNumDataGridViewTextBoxColumn.
arrayvar1[2] = THIS-OBJECT:nameDataGridViewTextBoxColumn.
arrayvar1[3] = THIS-OBJECT:addressDataGridViewTextBoxColumn.
arrayvar1[4] = THIS-OBJECT:city.
&.nbsp; THIS-OBJECT:dataGridView1:Columns:AddRange(arrayvar1).
THIS-OBJECT:dataGridView1:DataSource = THIS-OBJECT:bindingSource1.
THIS-OBJECT:dataGridView1:Location = NEW System.Drawing.Point(81, 59).
THIS-OBJECT:dataGridView1:Name = "dataGridView1".
THIS-OBJECT:dataGridView1:Size = NEW System.Drawing.Size(422, 180).
THIS-OBJECT:dataGridView1:TabIndex = 0.
THIS-OBJECT:dataGridView1:CellContentClick:SUBSCRIBE(THIS-OBJECT:dataGridView1_CellContentClick).
/* */
/* custNumDataGridViewTextBoxColumn */
/* */
THIS-OBJECT:custNumDataGridViewTextBoxColumn:DataPropertyName = "cust-Num".
THIS-OBJECT:custNumDataGridViewTextBoxColumn:HeaderText = "cust-Num".
THIS-OBJECT:custNumDataGridViewTextBoxColumn:Name = "custNumDataGridViewTextBoxColumn".
/* */
/* nameDataGridViewTextBoxColumn */
/* */
THIS-OBJECT:nameDataGridViewTextBoxColumn:DataPropertyName = "Name".
THIS-OBJECT:nameDataGridViewTextBoxColumn:HeaderText = "Name".
THIS-OBJECT:nameDataGridViewTextBoxColumn:Name = "nameDataGridViewTextBoxColumn".
/* */
/* addressDataGridViewTextBoxColumn */
/* */
THIS-OBJECT:addressDataGridViewTextBoxColumn:DataPropertyName = "Address".
THIS-OBJECT:addressDataGridViewTextBoxColumn:HeaderText = "Address".
THIS-OBJECT:addressDataGridViewTextBoxColumn:Name = "addressDataGridViewTextBoxColumn".
/* */
/* city */
/* */
THIS-OBJECT:city:DataPropertyName = "city".
THIS-OBJECT:city:HeaderText = "city".
THIS-OBJECT:city:Name = "city".
/* */
/* ProbindingQuery */
/* */
THIS-OBJECT:ClientSize = NEW System.Drawing.Size(712, 557).
THIS-OBJECT:Controls:Add(THIS-OBJECT:dataGridView1).
THIS-OBJECT:Name = "ProbindingQuery".
THIS-OBJECT:Text = "ProbindingQuery".
THIS-OBJECT:Load:SUBSCRIBE(THIS-OBJECT:ProbindingQuery_Load).
CAST(THIS-OBJECT:bindingSource1, System.ComponentModel.ISupportInitialize):EndInit().
CAST(THIS-OBJECT:dataGridView1, System.ComponentModel.ISupportInitialize):EndInit().
THIS-OBJECT:ResumeLayout(FALSE).
CATCH e AS Progress.Lang.Error:
&.nbsp; UNDO, THROW e.
END CATCH.
END METHOD.
/*------------------------------------------------------------------------------
Purpose:
Notes:
------------------------------------------------------------------------------*/
@VisualDesigner.
METHOD PRIVATE VOID ProbindingQuery_Load( INPUT sender AS System.Object, INPUT e AS System.EventArgs ):
open query q for each Customer .
/* open the query for the customer and associate the query handle with the
binding source*/
bindingSource1:Handle = query q:handle.
RETURN.
END METHOD.
DESTRUCTOR PUBLIC ProbindingQuery ( ):
IF VALID-OBJECT(components) THEN DO:
CAST(components, System.IDisposable):Dispose().
END.
END DESTRUCTOR.
END CLASS..