Add data to msFlexGrid

Posted on 2006-05-19
Last Modified: 2013-12-25
I want to populate a msflexgrid in vb6.0 at runtime. Can someone please show me
First how to add a msflexgrid to a form
them to populate the columns of this grid from textbox or values from memory..

Thank you,
Question by:Aiysha
    LVL 2

    Accepted Solution

    You need to add a Flexgrid control to a form..  For this instance name it FG

    With FG
        .Cols = 4
        .Rows = 1
        .TextMatrix(0, 0) = "Qty"
        .TextMatrix(0, 1) = "Product Code"
        .TextMatrix(0, 2) = "Description"
        .TextMatrix(0, 3) = "Location"
        .ColWidth(0) = 400
        .ColWidth(1) = 1250
        .ColWidth(2) = 2175
        .ColWidth(3) = 1000
    End With

    This will set up a flexGris with 1 Row and 4 colums.  It will add data to the colum headings.

    Now add a command button

    ' add some data
    For x = 0 To 3
       With FG
        .AddItem "" ' Add a blank row
        .TextMatrix(x + 1, 0) = x
        .TextMatrix(x + 1, 1) = "1243132"
        .TextMatrix(x + 1, 2) = "This is test line" & x + 1
        .TextMatrix(x + 1, 3) = "Here"
       End With
    Next x

    Now add another command button to change a cell colour

    Private Sub Command2_Click()
    With FG
        .Row = 1
        .Col = 2
        .CellBackColor = &HFF
    End With
    End Sub

    This should get you started

    LVL 2

    Expert Comment

    Sorry,  Ad the first part to you form load procedure
    LVL 2

    Expert Comment

    To add the control at runtime, see

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now