How to Fill a FlexGrid Control With Data

Written by alexander gokhfeld
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Fill a FlexGrid Control With Data
FlexGrid control allows users to fill table forms with data.. (Jupiterimages/Photos.com/Getty Images)

The Microsoft Visual Basic for Applications FlexGrid (MSFlexGrid) control allows you to add and display text and images in the Windows Forms cells. It also includes the functions that give users the ability to sort, merge and format tables containing character strings and numerical data types. The FlexGrid control uses form initialisation and database connection procedures for populating user forms with data. You simply need to specify the location of cells on user forms in order to fill a FlexGrid control with data.

Skill level:
Moderately Easy

Other People Are Reading

Instructions

  1. 1

    Click the "Start" button in Windows, and then select "Microsoft Visual Studio."

  2. 2

    Click "Open." Locate and select the C++ program in which you want to fill a FlexGrid control with data in the "Open File" dialogue box.

  3. 3

    Type the following code in the declarations section of the UserForm:

    Public oDataBase As Database

    Public oWorkSpace As Workspace

    Public oRecordSet As Recordset

    Public strDB As String

    Public strDBTable As String

    Dim strDBField() As String ' Array for Database field names.

    Private Sub UserForm_Initialize()

      strDB = Options.DefaultFilePath(wdProgramPath) & _
    
      "\Samples\Northwind.mdb"
    
      ' Database Table To Use.
    
      strDBTable = "Customers"
    
      ' Database Field(s) To Use.
    
      ReDim strDBField(2)
    
      strDBField(0) = "CompanyName"
    
      strDBField(1) = "ContactName"
    
      strDBField(2) = "ContactTitle"
    
      DBConnect
    
      PopulateGridControl
    

    End Sub

    Sub DBConnect()

      Set oWorkSpace = CreateWorkspace(Name:="JetWorkspace", _
    
      UserName:="admin", Password:="", UseType:=dbUseJet)
    
      Set oDataBase = OpenDatabase(strDB)
    
      Set oRecordSet = oDataBase.OpenRecordset(strDBTable)
    

    End Sub

  4. 4

    Click "File" followed by "Save" to fill a FlexGrid control with data in your C++ program.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.