FlexGrid Control of VB

Source: Internet
Author: User
Tags bind dsn insert valid

Accessing the Hierarchical FlexGrid control
To install and access the Hierarchical FlexGrid control in Visual Basic, use the following procedure.
To install and access the Hierarchical FlexGrid control
1. From the "Project" menu, select "Part". The Parts dialog box appears.
2. On the Controls tab, select Microsofthierarchical Flexgridcontrol 6.0, and then click OK. The MSHFlexGrid control is added to the Visual Basic Toolbox.
3. In the Visual Basic Toolbox, click the MSHFlexGrid control, and then drag it onto a Visual Basic form.
Or
On the Visual Basic Toolbox, double-click the MSHFlexGrid control to add it to the form.

Bind data to Hierarchical FlexGrid
Before you can begin to use its functionality, you must first bind the data to hierarchical FlexGrid. To bind data to a control, you can use Visual Basic's new data Binding Manager, or programmatically.
After binding the hierarchical FlexGrid to a data source, hierarchical FlexGrid the screen at design time is a blank column and a blank row. field and band information is not automatically extracted (see Obtaining structure information for this type of information). If the Hierarchical FlexGrid runs without field and stripe information, the default property settings will be used when displaying the data. That is, if the hierarchical FlexGrid is bound to a hierarchical command, the displayed data bands will be horizontal, with one column in each stripe corresponding to each field in the Recordset.
Hierarchical FlexGrid bound to a data source

Bind data to Hierarchical FlexGrid using visual Basicdata Binding Manager
This section describes how to use visual Basicdata Binding Manager Bind the data to the Hierarchical FlexGrid. Data Binding Manager provides a user interface that is easy to bind to.
Use the visual Basicdata Binding Manager to set DataSource
1. Create a data source for hierarchical FlexGrid. The data source can be either a DataEnvironment object or a Activexdata control, or a new Visual Basic feature. In this case, the data source is created as a DataEnvironment object.
2. On the Visual Basic Toolbox, click the MSHFlexGrid control, and then drag it onto a Visual Basic form.
-or-
on the Visual Basic Toolbox, double-click the MSHFlexGrid control to drag it onto a VisualBasic form.
3. In the Visual Basic Properties window, set the DataSource property to a DataEnvironment object that contains a Command object that you want to bind to hierarchical FlexGrid.
Warning If DataSource is reset, all user-defined, modified data in the Hierarchical FlexGrid cell will be lost. 4. In the Visual Basic Properties window, set the DataMember property to a Command object in DataEnvironment. If you want to view the data for a hierarchical structure in Hierarchicalflexgrid, you must specify the topmost parent command object in the Command hierarchy as the DataMember.
5. To view the data in the Hierarchical FlexGrid, select Start from the Run menu.
-OR-
press the F5 key.

To bind data to hierarchical FlexGrid programmatically
This section describes how to programmatically bind data to Hierarchical FlexGrid. To set the DataSource programmatically
1. In the Visual Basic Toolbox, double-click the MSHFlexGrid control to place it on a Visual Basic form.
2. Right-click the Hierarchical FlexGrid and choose View Code from the shortcut menu. The Code Editor window appears.
3. In the Form_Load event, add code to create an ADO Recordset and assign it to hierarchical FlexGrid. The code is provided in the following step-by-step steps.
Note to programmatically set up a data source, you must have a reference to the Microsoftactivex data Objects in the project: On the Project menu, select References, and then select Microsoft ActiveX Data Objects 2.0 Library. "
Insert the following code to create an ADO Connection and Recordset, replacing the annotations (for example, replacing <myDataSource> with the actual name of the data source) as appropriate:
DIM Cn as New Connection, Rs as New Recordset

' You need to replace <myDataSource> with your system
' A valid DSN in.
cn.connectionstring = "Dsn=<mydatasource>"

' Use the following code for SHAPE Commands
Cn.provider = "MSDataShape"
Cn.cursorlocation = Adusenone

' The second way, for SQL Commands, you can use the following code
Cn.cursorlocation = Adusenone
Cn.open
' needs to specify the recordsets for the Connection created above
' A valid data source

Rs.source = "<valid SQL SELECT command>"
' Now associate Command with Connection
' Get up and execute them.
Set rs.activeconnection = Cn
Rs.Open

Insert the following code to give Hierarchicalflexgrid the Recordset opened in Rs:
Set Mshflexgrid1.datasource = Rs
4. To view the data in the Hierarchical FlexGrid, select Start from the Run menu.
Or
Press the F5 key.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.