
MS Flex Grid Easy Question (I Hope)
Place a MSFlexgrid and a textbox with the visible property set to false on a
form and paste the following code to the form and press f5
Private Sub Form_Load()
msflexGrid1.Cols = 5
msflexGrid1.Rows = 10
msflexGrid1.HighLight = flexHighlightAlways
End Sub
Private Sub Grid1_KeyPress(KeyAscii As Integer)
With Text1
.Visible = True
.Width = msflexGrid1.CellWidth
.Height = msflexGrid1.CellHeight
.Left = msflexGrid1.CellLeft + msflexGrid1.Left
.Top = msflexGrid1.CellTop + msflexGrid1.Top
.Text = msflexGrid1.Text
.SetFocus
End With
If KeyAscii = 13 Then
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Else
Text1 = ""
SendKeys Chr$(KeyAscii)
End If
End Sub
Private Sub msflexGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyDelete
msflexGrid1 = ""
End Select
End Sub
Private Sub msflexGrid1_KeyPress(KeyAscii As Integer)
With Text1
.Visible = True
.Width = msflexGrid1.CellWidth
.Height = msflexGrid1.CellHeight
.Left = msflexGrid1.CellLeft + msflexGrid1.Left
.Top = msflexGrid1.CellTop + msflexGrid1.Top
.Text = msflexGrid1.Text
.SetFocus
End With
If KeyAscii = 13 Then
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Else
Text1 = ""
SendKeys Chr$(KeyAscii)
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 13
msflexGrid1.Text = Format$(Text1, "standard")
Text1.Visible = False
Case 27
Text1.Visible = False
End Select
End Sub
Quote:
> I am new to VB6 and I was trying to test some of the features of the flex
> grid. I wnat to be able to type into the cells, however, I do not seem to
be
> able to do it by default.
> Does anyone know how you set up the flex grid so it will accept simple
typed
> in information
> Thanks in advance, Tom