1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| Private Sub Form_Load()
MSHFlexGrid1.Cols = 2: MSHFlexGrid1.Rows = 15
MSHFlexGrid1.FixedCols = 1: MSHFlexGrid1.FixedRows = 0
MSHFlexGrid1.Move 120, 120, 2235, 2505
TextEntrer.Height = MSHFlexGrid1.RowHeight(1) - 15
Me.Height = 3180: Me.Width = 2610
Dim T As Integer
'Juste pour la demo
For T = 0 To 14
MSHFlexGrid1.TextMatrix(T, 0) = T
MSHFlexGrid1.TextMatrix(T, 1) = Chr(T + 65)
Next T
End Sub
Private Sub MSHFlexGrid1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim LeftText As Integer
Dim TopText As Integer
Dim WidthText As Integer
'pour definir le Left de la boite entrées du texte
LeftText = (MSHFlexGrid1.CellLeft + MSHFlexGrid1.Left) - 15
'pour ajuster le width de la boite entrées du texte
WidthText = MSHFlexGrid1.CellWidth
'pour definir le Top de la boite entrées du texte
TopText = (MSHFlexGrid1.CellTop + MSHFlexGrid1.Top) - 15
'pour remplir la boite entrées du texte avec le texte de la cellule active
TextEntrer.Text = MSHFlexGrid1.Text
'deplacement et recouvrement
'de la cellule active par la boite entrées du texte
TextEntrer.Move LeftText, TopText, WidthText
'donne le focus à la boite entrées du texte
TextEntrer.SetFocus
End Sub
Private Sub MSHFlexGrid1_Scroll()
'pour être sur que la boite entrées du texte ne soit pas visible
'durant le defilement des lignes
TextEntrer.Left = -TextEntrer.Width
End Sub
Private Sub TextEntrer_KeyPress(KeyAscii As Integer)
'gestion pour la modification d'une cellule texte du grid
If KeyAscii = 27 Then 'abandon
TextEntrer.Left = -TextEntrer.Width: Exit Sub
End If
If KeyAscii = 13 Then 'validation de la modification
KeyAscii = 0
MSHFlexGrid1.Text = TextEntrer.Text
TextEntrer.Left = -TextEntrer.Width
End If
End Sub |
Partager