Important: You do not have the latest version of CIMPLICITY! You are missing out on the newest capabilities and enhanced security. For information on all the latest features, see the CIMPLICITY product page. For more information on upgrades, contact your GE Digital sales agent or e-mail GE Digital Sales Support. For the most up-to-date documentation, go here.
.NET Example: Parameters Not Fully Converted
About this task
Because there are endless .NET event argument types, the common and most useful types will be converted first for the .NET Component Host; additional .NET argument types will be converted in future CIMPLICITY releases.
However, when parameters are not fully converted, the controls can be configured using CimEdit features, such as events, scripts and procedures.
A DataGrid and ComboBox, which are available in the .NET Component Browser, have properties of not fully converted data types that have these requirements.
Note: The DataGrid and ComboBox example:
Will be configured to display logged data in the DataGrid whose category can be selected in the ComboBox.
Uses the Microsoft SQL Server sample database Northwind.mdf/Mothwind.ldf files, which can be downloaded from the Microsoft Website.
Important: Before you work with or apply this example make sure that a Virtual integer point is available for the script.
The sample uses a point named SEL_INDEX.
Controls: Script - Part 1
Controls: Script - Part 2
Controls: Script - Part 1
Once a chart is placed on the screen, scripting can be started that will pull data into the control from SQL Server.
Since the ComboBox runtime representation displays a drop list arrow aiding you to approximate its size. You can modify the size later.
Open the ComboBox's Properties - Object dialog box.
Select General.
Name the ComboBox in the Object name field (e.g. Combo Box1).
Close the Properties - Object dialog box.
The controls
Note:Colors and fonts that are different from the default colors and fonts can be selected at anytime in the control's Properties - Object dialog box>Control Properties list.
Solid colors can be selected for the DataGrid rows.
Example
The following colors are selected for the DataGrid rows.
Row
RGB Color
AlternatingRowBackground_Color1
218,227,188
RowBackground_Color1
250,192,143
The DataGrid rows will alternate these colors during runtime.
Controls: Create a New Script
Scripts that will populate the DataGrid and ComboBox are based on a Screen Open event.
DataGrid: Create a Script - Part 1
ComboBox: Create a Script - Part 1
DataGrid: Create a Script - Part 1
Add a Screen Open event to the DataGrid control.
Create a new script.
Add the following code to the script.
Important: Change the information, if necessary, to match your database specifications.
Private cimOleObj As Occ_PresentationFramework.IOccDataGrid
Sub OnScreenOpen()
Dim conn As Object
Dim rs As Object
Set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
conn.ConnectionString = "Provider=SQLNCLI10;Data Source=.\sqlexpress;" _
& "AttachDbFilename=C:\SQLSampleDatabases\NORTHWND.MDF;Integrated Security=SSPI;"
conn.Open
rs.Open "Select Top 20 * from Orders", conn
Set cimOleObj.ItemsSource = rs
rs.Close
conn.Close
End Sub
Compile the script; close the Edit Script window.
Close the DataGrid's Properties - Object dialog box.
ComboBox: Create a Script - Part 1
Add a Screen Open event to the ComboBox control
Create a new script.
Add the following code to the script.
Important: Change the information, if necessary, to match your database specifications.
Private cimOleObj As Occ_PresentationFramework.IOccComboBox
Sub OnScreenOpen()
Dim conn As Object
Dim rs As Object
Set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
conn.ConnectionString = "Provider=SQLNCLI10;Data Source=.\sqlexpress;" _
& "AttachDbFilename=C:\SQLSampleDatabases\NORTHWND.MDF;Integrated Security=SSPI;"
conn.Open
rs.Open "Select Top 20 * from Orders", conn
Do While Not rs.EOF
cimOleObj.Items.Add CStr(rs("CustomerID"))
rs.MoveNext
Loop
cimOleObj.SelectedIndex = 0
rs.Close
conn.Close
End Sub
Compile the script; close the Edit Script window.
Close the ComboBox's Properties - Object dialog box.
Controls: Test the Script - Part 1
The controls should now display data from the selected database (e.g. Northwind).
A user can:
A
Scroll up and down the DataGrid to review data.
B
Select different items on the ComboBox drop down list.
There is currently no connection between the DataGrid and the ComboBox.
Controls: Script - Part 2
When two additional scripts are applied to a procedure, they will connect the two .NET controls and cause the ComboBox selection to drive the DataGrid display.
The .NET controls subroutines get and set the Virtual point that you created or selected for use before placing the controls on the CimEdit screen.
ComboBox: Add a Subroutine
A ComboBox subroutine sets the point (e.g. SEL_INDEX).
This is the companion to the DataGrid subroutine that will get the point.
Sub GetSelection()
PointSet "SEL_INDEX", cimOleObj.SelectedIndex
End Sub
DataGrid: Add a Subroutine
A DataGrid subroutine gets the point (e.g. SEL_INDEX).
This is the companion to the ComboBox subroutine that will set the point.
Sub SetSelection()
cimOleObj.SelectedIndex = PointGet("SEL_INDEX")
End Sub
Controls: Create a Procedure to Invoke the Scripts
Note:
Because the two parameters are of the COM Variant type, it's not as straightforward to use a handler routine as, for example, Mouse events.
However, because both the DataGrid and ComboBox each have the SelectionIndex property, the selection in the ComboBox drop down list can be determined and the corresponding row selection of the DataGrid component can be set by accessing their SelectionIndex properties.
A straightforward way to configure the parameters is through an ActiveX Event>SelectionChanged event and a procedure that uses InvokeScript actions.
ComboBox: Configure SetChangedProc
DataGrid: Configure SetChangedProc
ComboBox: Configure SetChangedProc
Open the ComboBox Properties - Object dialog box.
Select Events.
Create an ActiveX Event>SelectionChanged event.
Create a new procedure for the event.
The procedure Includes two Invoke script actions.
1
Procedure name
Name to clearly identify the procedure.
Example
SetChangedProc
2
Action type 1
Invoke script
3
Object name1
Select the name that was entered in the ComboBox's Properties - Object dialog box>General>Object name field.
Example
Combo Box1
4
Method1
GetSelection
2
Action type 2
Invoke script
3
Object name2
Select the name that was entered in the DataGrid's Properties - Object dialog box>General>Object name field
Example
DataGrid1
4
Method
SetSelection
Click Apply; close the ComboBox control's Properties - Object dialog box.
DataGrid: Configure SetChangedProc
Configure the same ActiveX Event>Selection Changed event with the same SetChangedProc in the DataGrid control's Properties - Object dialog box.
Controls: Test Scripts and Procedures -
If the scripts and configuration are completed correctly the DataGrid control now automatically highlights the data row based on the selection made in the ComboBox control.