Merged data views

To create merged data views, you start by populating the grid. For example, you may bind it to a database. Then, set the MergeCells property to flexMergeRestrictAll and MergeCol(-1) to True. Notice that the -1 index means "apply this setting to all columns".

The code below show an example. It uses an ADO/OLEDB VSFlexGrid control named fg and a Microsoft ADO Data Control named Adodc1:

Private Sub Form_Load()

   

   ' create the data source

   Adodc1.ConnectionString = "DSN=NorthWind"

   Adodc1.CommandType = adCmdText

   Adodc1.RecordSource = "SELECT Country, City, " & "CompanyName FROM Customers;"

   Adodc1.Refresh

   Adodc1.Recordset.Sort = "Country, City"

  

   ' populate the grid

   Set fg.DataSource = Adodc1

      

   ' activate merging for all columns

   fg.MergeCells = flexMergeRestrictAll

   fg.MergeCol(-1) = True

End Sub

This is the result: