I need to use an editable grid in my application. As far as I know MSFlexGrid is uneditable. I know that there is a control called Sheridan grid but I don't know the name of the company that produces it. Any ideas - any other grid that I can use?
i am having the very same problem. the only solution i came up with, and never implimented for obvious reasons, was to make a big table of lines and text boxes. i made one look good so if all else fails you can use this ugly method
My problem is that there is a list box with some API names and depending on which one the user selects, the grid has to display its parameters. So the number of columns in the grid depends on the user's selection. Also the user has to be able to enter and I don't want to fiddle with dynamic creation of textboxes at run-time using a control array.
Sheridan was recently bought out. The new company is still continuing the grid controls and it looks like they'll be improving them with newer versions. The grids do what you are looking for. Here's the link
Although flexgrids are technically not editable, such behavior can be faked by sizing a textbox over the cell the user clicks on. The text from the textbox can then be entered in the flexgrid programmatically. Check out
You mentioned that your project had a grid that depending on hte user selection the grid would display a different number of columns. Can you give me some additional information on how you did that?
You are correct, FlexGrid does not allow for direct editing. But there is a workaround to give the appearance of editing. Here is some sample code that you may find useful.
There are several steps for this.
1) On your form, first place the Grid (grdGrid). Then on top of the grid, add a TextBox (txtGrid) and a ComboBox (cboGrid)
2) Set the .Visible property of both the combobox and the Textbox to False
In your form, drop in the following three event handlers
Private Sub grdGrid_Click()
Select Case grdGrid.Col
Case 0, 3, 5 ' Columns that need Text Boxes
ActivateControl txtGrid, grdGrid
Case 1, 2, 4 ' Columns that need a Combo Box
<Load the Combo Box with Values>
ActivateControl cboGrid, grdGrid
Case Else
' Column is not editable
End Select
End Sub
Private Sub cboGrid_LostFocus()
ResetSetGrid cboGrid, grdGrid
End Sub
Private Sub txtGrid_LostFocus()
ResetSetGrid txtGrid, grdGrid
End Sub
Now in a module (or in the same form), drop in the following two public subroutines
Public Sub ActivateControl(rCtl_Control As Control, rGrd_grdGrid As MSHFlexGrid)
rCtl_Control.Top = rGrd_grdGrid.Top + rGrd_grdGrid.CellTop - 20
rCtl_Control.Left = rGrd_grdGrid.Left + rGrd_grdGrid.CellLeft - 20
rCtl_Control.Tag = Trim(rGrd_grdGrid) & "," & Trim(rGrd_grdGrid) I usually prefer a minimum width (1800) for the control, otherwise go as wide as that column
rCtl_Control.Width = IIf((rGrd_grdGrid.CellWidth < 1800), 1800, rGrd_grdGrid.CellWidth)
If (TypeName(rCtl_Control) = "TextBox" Then
rCtl_Control.Height = rGrd_grdGrid.CellHeight
End If
rCtl_Control.Text = rGrd_grdGrid.Text
rCtl_Control.Visible = True
rCtl_Control.Enabled = True
rCtl_Control.SetFocus
End Sub
Public Sub ResetSetGrid(rCtl_Control As Control, rGrd_grdGrid As MSHFlexGrid)
Another solution, although I have never used it so don't know how flexible/useful it is, is to use the spreadsheet component of Microsoft Office Web Component. You can modify it to remove the toolbar and title
Apparently, I made a mistake during the copy and paste. The
.Tag assignment line in Public Sub ActivateControl subroutine should read as follows:
rCtl_Control.Tag = Trim(rGrd_grdGrid.Row) & "," & Trim(rGrd_grdGrid.Col)
Good Luck
-------------- As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.