Msflexgrid Vba Instant
Private Sub SetupGrid() With Me.fgData .Cols = 4 .Rows = 2 .FixedRows = 1 .TextMatrix(0, 0) = "Product" .TextMatrix(0, 1) = "Qty" .TextMatrix(0, 2) = "Price" .TextMatrix(0, 3) = "Total" .ColWidth(0) = 2000 .ColWidth(1) = 800 .ColWidth(2) = 1200 .ColWidth(3) = 1500 End With End Sub
If rowToDelete = 0 Then MsgBox "Cannot delete header row", vbExclamation Exit Sub End If msflexgrid vba
Me.fgData.RemoveItem rowToDelete End Sub : RemoveItem is available in MSFlexGrid 6.0. For older versions, shift rows manually. 4.7 Sort by Column Private Sub fgData_HeadClick(ByVal Col As Integer) ' Sorts when user clicks a header With Me.fgData .Sort = flexSortGenericAscending .Col = Col .Row = 0 ' Optionally store sort column for toggle End With End Sub 5. Common Gotchas & Solutions | Problem | Solution | |---------|----------| | Text not wrapping | Set .WordWrap = True and ensure .ColWidth is fixed. | | Scrollbar not showing | Increase .Rows or .Cols beyond visible area. | | Slow with many rows | Disable redraw: .Redraw = False → load data → .Redraw = True | | Double-click not firing | Use DblClick event, not Click . | | Can't edit cells | MSFlexGrid is read-only by design. Use a TextBox overlay for editing. | | Row height too small | Set .RowHeightMin property or individual .RowHeight(row) . | 6. Advanced: In-Cell Editing (TextBox Overlay) Since MSFlexGrid doesn't support native editing, use a hidden TextBox: Private Sub SetupGrid() With Me