Somebody know if we can allow the user to enter data in MSFlexGrid. If not, witch control (like a grid) I have to use. :confused: :confused: :confused:
Printable View
Somebody know if we can allow the user to enter data in MSFlexGrid. If not, witch control (like a grid) I have to use. :confused: :confused: :confused:
You need to place a text box over the cell clicked into, and get the user to type the entry into this. When the focus is lost from the text box, the entry is updated :
This is what I used. If you look in the MSDN samples that come with VB, there a project called MSFlexgd.vbp, which is a sample app of using the flexgrid controlCode:Private Type FlxCell
row As Long
col As Long
End Type
'Set up a new type used to define a cell in the flexgrid
'- this includes 2 number variables, to reference in the row & column.
Private Active_FlxCell As FlxCell
'Introduce new variable for above created cell / new type.
Private Sub FlxGrd_dblClick()
If FlxGrd.row > 0 And FlxGrd.col = 2 Then
Active_FlxCell.row = FlxGrd.row
Active_FlxCell.col = FlxGrd.col
'If a cell is selected, check if this is the top row (which would be the heading)
FlxGrd.ScrollBars = flexScrollBarNone
'User can't scroll down until the cell has been unselected.
With TxtEdit
.Top = FlxGrd.CellTop + FlxGrd.Top
.Left = FlxGrd.CellLeft + FlxGrd.Left
.Width = FlxGrd.CellWidth
.Text = FlxGrd.Text
.Visible = True
.ZOrder
.SetFocus
End With
'Set the size of the textbox to fit around the selected cell, make it
'visible for the user to see, and copy the active cell's text inside the text box.
End If
End Sub
Private Sub TxtEdit_LostFocus()
FlxGrd.ScrollBars = flexScrollBarBoth
'Place scrollbars back onto the Flexgrid control.
If Not IsNull(TxtEdit.Text) Then
'user typed an entry in the text box
FlxGrd.TextMatrix(Active_FlxCell.row, Active_FlxCell.col) = TxtEdit.Text
End If
End Sub
thank you, it's exactly what i want!!!
But I still have a question.
I can't change the width of my cells...
And can the cells have different size than the others???
You need to do this in your code at startup. I.e. -
Code:Private Sub Form_Load()
With MSFlexGrid1
.ColWidth(0) = 1000
.ColWidth(1) = 1000
.ColWidth(2) = 1000
End With
End Sub
I have a simple question....
Why I haven't found it alone...
Thanks!!!