Flex Grid control in Visual Basic

Asked By 10 points N/A Posted on -

I’m using the Flex Grid control in my program using Visual Basic 6. How can I populate and edit the data in Flex Grid?

I have 6 fields ID, Last name, First name, Middle name, Course, and Year in which all of these must be editable.

I am using DAO to an Access database.

Answered By 0 points N/A #126133

Flex Grid control in Visual Basic


You can edit the data on the Flex Grid by extracting or passing the values of a selected cell to a text box. The whole row will be editable; if you want to exclude a certain column then you have to specify what columns to be displayed on Data Grid.

Double click the Flex Grid and follow the codes below:

Call the connection

With [Recordset]


    .Move Fgrid.Row – 1

    txtid.Text = Fgrid.TextMatrix(Fgrid.Row, 0)

    txtLast.Text = Fgrid.TextMatrix(Fgrid.Row, 1)

    txtFirst.Text = Fgrid.TextMatrix(Fgrid.Row, 2)

    txtMiddle.Text = Fgrid.TextMatrix(Fgrid.Row, 3)

    txtCourse.Text = Fgrid.TextMatrix(Fgrid.Row, 4)

    txtpath.Text = Fgrid.TextMatrix(Fgrid.Row, 5)

End With


Create a function in populating the Flex Grid.

Private Function FILLGRID()

Call the connection

With Fgrid

    Fgrid.Cols = rsstudent.Fields.Count + 1

    Fgrid.ColWidth(6) = 6

    For c = 0 To rsstudent.Fields.Count – 1

    Fgrid.TextMatrix(0, c) = rsstudent(c).Name


    Fgrid.Rows = rsstudent.RecordCount + 1

    For r = 1 To rsstudent.RecordCount

    For c = 0 To rsstudent.Fields.Count – 1

    Fgrid.TextMatrix(r, c) = IIf(IsNull(rsstudent(c).Value), "(Null)", rsstudent(c).Value)

Next c


Next r

End With

End Function

Login/Register to Answer

Related Questions