共用方式為


ADO Data-Bound Controls

The following data-bound controls display data from the ADO Data Control. See Inserting the Control into a Visual C++ Application and Setting Control Properties at Design Time for information on using ActiveX controls.

Control Name and Support Files Description
Microsoft DataCombo

Msdatlst.ocx

DBList98.chm

The DataCombo control allows retrieved data to appear in a drop-down combo box.

To link the DataCombo control to a data source

  1. Set the DataSource and the RowSource properties to an ADO Data Control.

  2. Set the DataField and ListField properties to the desired fields.

DataSource and DataField govern the active value of the control. RowSource and ListField allow the display of column data other than the current record. You can also set BoundColumn; this property represents the value of the control when it is made into a variable in an MFC application.

Microsoft DataGrid

Msdatgrd.ocx

DBGrid98.chm

DataGrid can hold text data, but not linked or embedded objects. The AllowAddNew, AllowDelete, and AllUpdate properties allow the DataGrid to modify data.
Microsoft DataList

Msdatlst.ocx

DBList98.chm

The DataList control allows retrieved data to appear in a drop-down list box.

To link the DataList control

  1. Set the DataSource and the RowSource properties to an ADO Data Control.

  2. Set the DataField and ListField properties to the desired fields.

DataSource and DataField govern the active value of the control. RowSource and ListField allow the display of column data other than the current record. You can also set the BoundColumn value. This value represents the value of the control when it is made into a variable in an MFC application.

Microsoft DataRepeater

Msdatrep.ocx

DatRpt98.chm

The DataRepeater control is a composite control; a control that hosts other controls. It allows you to specify a control to repeat, and when bound, displays the selected control for each record retrieved. The DataRepeater will then allow end users to scroll through the retrieved records.

To link the DataRepeater control

  1. In the All property tab, set the DataSource property to an ADO Data Control.

  2. In the All property tab, select a control to repeat for the Repeated Control Name property.

  3. Once a control is selected, go to the RepeaterBindings tab.

  4. Set a property name to bind. The drop-down box will enumerate bindable properties in the control to be repeated.

  5. Set a data field. The drop-down box will enumerate column names returned from the bound ADO Data Control.

  6. Click on the Add button to add the binding. The RepeaterBindings list box will then populate with the new binding.

The DataRepeater control also ships separately with Visual Studio 6.0.

Microsoft Hierarchical FlexGrid

Mshflxgd.ocx

MsHFlx98.chm

The Hierarchical FlexGrid control displays tabular data. Unlike the DataGrid, it is strictly read-only. However, it can sort, merge, and format tables containing strings and pictures. Additionally, the Hierarchical FlexGrid differs from its predecessor, the FlexGrid, in that it can display both summary data and detail data.

A hierarchical rowset is required to display summary-detail information in the Hierarchical FlexGrid control. To create a hierarchical rowset for this control, the Microsoft Data Shape Provider is required in combination with the ADO Data Control.

To use the Hierarchical FlexGrid

  1. Use the ADO Data Control to set the ConnectionString property to specify the Microsoft Data Shape Provider. For example:

    Provider=MSDataShape.1;Data Source=myPubsDataSource;User ID=sa
  1. Set the RecordSource property to use Microsoft Data Shape Provider syntax to create a hierarchical rowset. For example:

    SHAPE {select * from authors} APPEND ({select * from titleauthor} AS chapter RELATE au_id TO au_id)
  1. Set the DataSource property of the Hierarchical FlexGrid control to the ADO Data Control configured above.

For additional information on data shaping see the topic Hierarchical Cursors and Data Shaping in the ADO Programmer's Reference.

Microsoft Chart

Mschart.ocx

MSchrt98.chm

The Chart control displays an array of data as a graph. It can display both two-dimensional and three-dimensional graphs. When data-bound, it treats the retrieved rowset as an array of data.

To link the Chart control

  1. Set the DataSource property to an ADO Data Control.

It is recommended that the ADO Data Control's database query retrieve a rowset of aggregate information such as count(*), sum(*), min(*), and max(*).

Previous versions of the MS Chart control were RDO based.

Note   The Chart control ships with Visual Studio 6.0 (not Visual C++), so you must have a Visual Studio 6.0 license to redistribute it.

Back to ActiveX Controls that Support Databinding.