Objective Grid Sample
Following similar steps to the sequence proposed for the Objective Views sample, we port an Objective Grid project into a C# project. The related sample is located in the following folder of your Objective Grid installation:
<installdir>\Samples\Grid\Integration with .Net\GridForm\GridForm
In this sample, marshaling data with Platform Invoke is demonstrated for the following data objects:
*Strings, in functions SetValueRowCol and GetValueRowCol
*Structure with strings, in functions SetStyleRange and GetStyleRowCol
*Array of strings, in functions SetValuesArray and GetValuesArray
To adjust message handling, the PreProcessMessage, ProcessDialogKey and ProcessCmdKey functions have been overridden.
Building the Objective Grid Sample
When testing this sample, you should set the build configuration for Objective Grid to Unicode static debug (OG903ud.lib). In the DLL properties, select Linker | Output File and set it to "../SharpTest/bin/Debug/OGDlg.dll". This places the DLL file into the C# project's bin/Debug folder, which allows us to build both projects at once.
To run this program in the ANSI configuration, the following changes should be made for the C# program:
*Replace Auto (in Attributes) with Ansi.
*Change the character set within the DLL properties either to Not Set or Multi-Byte.
Testing the Objective Grid Sample
When running the sample, you can test the following features:
*Set any cell as current by clicking on it:
*SetValueRowCol button: sets text "Text from C#", as shown in Figure 22, “Using the SetValueRowCol Button,”
*GetValueRowCol button: shows a .NET dialog with current cell’s text
*GetStyleRowCol button: shows a .NET dialog with style settings.
Figure 22 – Using the SetValueRowCol Button
*Set current cell or select a range:
*SetStyleRange - sets style (hardcoded in C#) to selected cell or range, as shown in Figure 23, “Using the SetStyleRange Button.”
Figure 23 – Using the SetStyleRange Button
*Select a range:
*SetValuesArray button: sets values in selected range to values in array (hardcoded in C#).
*GetValuesArray button: shows a .NET dialog with values from selected range, as shown in Figure 24, “Using the GetValuesArray Button.”
Figure 24 – Using the GetValuesArray Button
*To switch focus from Grid to WinForm controls, press Ctrl + Tab. To switch back, press Tab.
*Test arrows and tab keys on Grid.