Representation of data is one the central aspects of any application. Tabular representation of data is the most common method of representing given data. Each language/framework provides its own technique, in the form of controls, to present data in tabular format. MFC (Microsoft Foundation Classes) is no exception. One of the controls that it provides is the MSFlexGrid control.
Programming MSFlexGrid in MFC (VC++) - Using MSFlexGrid: Step by Step (Page 2 of 4 )
The following are the steps required to use MSFlexGrid in an application.
1. Including MSFlexGrid in the project.
2. Setting up the properties of the MSFlexGrid.
3. Declaring an MSFlexGrid variable and using it.
Of these, the first step is divided into different sub-steps.
Including MSFlexGrid in the project
Since FlexGrid is also an ActiveX control, the steps to include it in a project are the same as for adding any other ActiveX control. First, you must open the Components and Controls dialog by selecting it from the Add To Project sub-menu of Project menu. The dialog box that comes up contains all the ActiveX controls that can be added to the current project.
Next, in the dialog box, select "Registered ActiveX Controls." From the new list that appears, select "Microsoft Hierarchical FlexGrid Control." Click on the Insert button to add the control to the current project. The added control will appear in the resource editor's Controls toolbar.
If the control needs to be used as part of a dialog (which is usually the case), perform the steps for adding the controls to a dialog.
Setting up the properties of the MSFlexGrid
The next step is to set up the properties of the FlexGrid. The easiest way is to use the Properties Page to change the default properties to the required values. The other way is to do it programmatically. However, to do so, a declaration of a variable corresponding to the FlexGrid is needed.
Declaring MSFlexGrid variable and using it
Using the "Add Member Variable," add a variable for FlexGrid. This variable can be used to either change the properties of the FlexGrid or to call the FlexGrid's methods. For example, if the name of the declared variable is m_Edit_Grid, then one would clear the existing values in the FlexGrid by calling the clear method. The statement would be:
m_Edit_Grid.clear();
That completes the second section. The next section will focus on a small application that will use the MSFlexGrid control.