
How to create a data bound control that binds to a row
In VB6 I'm trying to understand complex data binding so tried to create an
example of a control that binds to a row of data. I can't get it to work and
would appreciate any advice on how to fix it. These were the steps I tried.
- Start a new ActiveX control project and add a flex grid with 10 columns to
UserControl1.
- Set UserControl1's DataBindingBehavior property to 2-vbComplexBound.
- Give UserControl1 a Clip property which delegates to the flex grid's Clip
property using the following code
Public Property Get Clip() As String
Clip = MSFlexGrid1.Clip
End Property
Public Property Let Clip(ByVal vNewValue As String)
MSFlexGrid1.Clip = vNewValue
End Property
- Tick all the data binding options in the Clip property's procedure
attributes.
- Put UserControl1 in run mode, add a standard EXE test project and place an
instance of UserControl1 (called MyCtl) on Form1.
- Add a data control (Data1) to Form1 and point it to the Employees table in
the Northwind example database.
- Set MyCtl's properties as follows:
DataSource - Data1
DataField - EmployeeID
- Make the test project the start up project and run it. EmployeeID appears
in the first non-fixed column of the flex grid but all other columns are
empty.
- Set MyCtl's DataField property to blank and run the test project. All
columns in the flex grid are empty.
At this point I ran out of ideas. Thanks in advance for any help.