• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1581
  • Last Modified:

Editable Flex Grid

1) How to make Flex Grid or Data Grid editable in vb6.Do we have any other editable grid control in vb6.
2) how to embed Excel sheet on any VB form.
1 Solution
1) flexgrid cannot be editable .. the other grid provided by microsoft is datagrid
2) what do u mean by embed .. do u just want to open and display an excel sheet .. u could look at OLE or reference to Excel objects within ur project and use them to open an excel application and ur workbook
have a look at this link provided by microsoft .. shows how u could code to make ur flexgrid editable ...

there are also some third party controls like sharpgrid, spread control, VSFlexgrid, shridian controls etc which provide good functionalities .. like the one u require and also adding combos, checkbox within cells etc ..
FlexGrid is not editable by default, but you can use KeyPress event to make it editable.

For example:

Private Sub Form_Load()
    MSFlexGrid1.Rows = 5
    MSFlexGrid1.Cols = 5
End Sub

Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)
    With MSFlexGrid1
        Print KeyAscii
        If KeyAscii = 8 And Len(.Text) > 0 Then .Text = Left(.Text, Len(.Text) - 1)
        If KeyAscii >= 32 And KeyAscii <= 128 Then
            .Text = .Text & Chr(KeyAscii)
        End If
    End With
End Sub
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Cool thing dbrckovi, I never thought that making a flexgrid editable would be that easy...
Well yes, it's easy to create basic edit functions, but some things are still not possible as far as I know.

For example, I never managed to create blinking cursor, or find an easy way to edit middle of the text in a cell.

Another possibility would be to do the Excell-style editing. For example, create a textbox next to the flexgrid and keep it updated with the contents of the selected cell.
In textbox's Change event, update the selected cell.


To embed an excell sheet on your form just create WebBrowser control (Project -> Components -> Microsoft Internet Controls)
and use it's Navigate function:

WebBrowser1.Navigate "d:\download\rosenthal.xls"
Many developers have written wrappers or templates for flexgrid to make it editable.  This is the one I use.  It's object-oriented and allows input validation on a column-by-column basis.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now