Placer une boite texte sur une cellule d'un MSFlexGrid
1 réponse
Raymond Fournier
Bonjour a tous,
J'utilise un contrôle MSFlexGrid qui lui est dans un contrôle
picture. Je place une boite de texte sur les cellules pour entrer du texte
dans la grille. Je rencontre le problème que ma boute de texte ne commence
pas au début de la cellule mais léger ment en avant. voici le code que
j'utilise pour placer ma boite de texte:
Tout est correct la largeur, la hauteur, le .top mais pas le .left.
Le contrôle picture commence à 0,0 de ma form, ainsi que le MSFlexGrid qui
est à 0,0 du contrôle picture.
Private Sub MSFlexGrid1_DragOver(Source As Control, x As Single, y As Single, State As Integer) PositionCol = MSFlexGrid1.MouseCol PositionRow = MSFlexGrid1.MouseRow Text1 = PositionCol Text3 = PositionRow
If PositionCol = 0 Or PositionRow = 0 Then Source.DragIcon = LoadPicture("C:DaviwebICONEmisc06.ICO") Else 'Source.DragIcon = LoadPicture("C:DaviwebICONEpoint02.ICO") Source.DragIcon = LoadPicture() End If
Select Case State 'Case vbEnter Case vbLeave Text2.Drag (vbCancel) Source.DragIcon = LoadPicture() End Select
End Sub
Private Sub MSFlexGrid1_Scroll() Text2.ZOrder 1 End Sub
Private Sub Text1_LostFocus() MSFlexGrid1.Col = 1 MSFlexGrid1.Row = 1 End Sub
Private Sub Text2_GotFocus() MSFlexGrid1.Text = Text2.Text Text2.SelStart = Len(Text2)
If MSFlexGrid1.Col >= MSFlexGrid1.Cols Then MSFlexGrid1.Col = 1 ChangeCellText End Sub
Private Sub MSFlexGrid1_EnterCell() ' Assigne texte cellule au textbox Text2.Text = MSFlexGrid1.Text End Sub
Private Sub MSFlexGrid1_LeaveCell() ' Assigne textbox value a la grille
MSFlexGrid1.Text = Text2.Text Text2.Text = "" End Sub
Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, _ x As Single, y As Single) posicol = MSFlexGrid1.MouseCol posirow = MSFlexGrid1.MouseRow
UsingMouse = True MSFlexGrid1.Text = Text2.Text ChangeCellText End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then MSFlexGrid1.Text = Text2.Text Text2.ZOrder 1 End If
End Sub
Private Sub Text2_LostFocus() If UsingMouse = True Then UsingMouse = False Exit Sub End If
If MSFlexGrid1.Col <= MSFlexGrid1.Cols - 2 Then MSFlexGrid1.Col = MSFlexGrid1.Col + 1 ChangeCellText Else If MSFlexGrid1.Row + 1 < MSFlexGrid1.Rows Then MSFlexGrid1.Row = MSFlexGrid1.Row + 1 MSFlexGrid1.Col = 1 ChangeCellText End If End If End Sub
Public Sub ChangeCellText() ' deplacement Textbox a la cell active. Text2.Move MSFlexGrid1.Left + MSFlexGrid1.CellLeft, _ MSFlexGrid1.Top + MSFlexGrid1.CellTop, _ MSFlexGrid1.CellWidth, MSFlexGrid1.CellHeight Text2.SetFocus Text2.ZOrder 0 End Sub
a+ Jean-Pol DAVID mailto: www.peintures-david.com ICQ 28394733 -- Quis ? Quid ? Ubi ? Quibus auxiliis ? Cur ? Quomodo ? Quando ? "Raymond Fournier" <duracelle(Enlever-ceci)@sympatico.ca> a écrit dans le message de news:
Bonjour a tous, J'utilise un contrôle MSFlexGrid qui lui est dans un contrôle picture. Je place une boite de texte sur les cellules pour entrer du texte dans la grille. Je rencontre le problème que ma boute de texte ne commence pas au début de la cellule mais léger ment en avant. voici le code que j'utilise pour placer ma boite de texte:
Tout est correct la largeur, la hauteur, le .top mais pas le .left. Le contrôle picture commence à 0,0 de ma form, ainsi que le MSFlexGrid qui est à 0,0 du contrôle picture.
Merci si vous avez une solution.
Raymond Fournier
Bonjour Raymond,
Voila 1 copier/coller
de mon programme.
Option Explicit
Private UsingMouse As Boolean ' drapeau pr Mouse ds la grille.
Dim PositionCol
Dim PositionRow
Dim posicol
Dim posirow
Private Sub Form_Load()
'Text1.TabIndex = 1
'Text2.TabIndex = 2
Text2.BorderStyle = 0
'Text3.TabIndex = 3
MSFlexGrid1.Cols = 5
MSFlexGrid1.Rows = 10
MSFlexGrid1.TabStop = False
Text2.DragMode = 1
End Sub
Private Sub MSFlexGrid1_DragDrop(Source As Control, x As Single, y As
Single)
Private Sub MSFlexGrid1_DragOver(Source As Control, x As Single, y As
Single, State As Integer)
PositionCol = MSFlexGrid1.MouseCol
PositionRow = MSFlexGrid1.MouseRow
Text1 = PositionCol
Text3 = PositionRow
If PositionCol = 0 Or PositionRow = 0 Then
Source.DragIcon = LoadPicture("C:DaviwebICONEmisc06.ICO")
Else
'Source.DragIcon = LoadPicture("C:DaviwebICONEpoint02.ICO")
Source.DragIcon = LoadPicture()
End If
Select Case State
'Case vbEnter
Case vbLeave
Text2.Drag (vbCancel)
Source.DragIcon = LoadPicture()
End Select
End Sub
Private Sub MSFlexGrid1_Scroll()
Text2.ZOrder 1
End Sub
Private Sub Text1_LostFocus()
MSFlexGrid1.Col = 1
MSFlexGrid1.Row = 1
End Sub
Private Sub Text2_GotFocus()
MSFlexGrid1.Text = Text2.Text
Text2.SelStart = Len(Text2)
If MSFlexGrid1.Col >= MSFlexGrid1.Cols Then MSFlexGrid1.Col = 1
ChangeCellText
End Sub
Private Sub MSFlexGrid1_EnterCell() ' Assigne texte cellule au textbox
Text2.Text = MSFlexGrid1.Text
End Sub
Private Sub MSFlexGrid1_LeaveCell()
' Assigne textbox value a la grille
MSFlexGrid1.Text = Text2.Text
Text2.Text = ""
End Sub
Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, _
x As Single, y As Single)
posicol = MSFlexGrid1.MouseCol
posirow = MSFlexGrid1.MouseRow
UsingMouse = True
MSFlexGrid1.Text = Text2.Text
ChangeCellText
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
MSFlexGrid1.Text = Text2.Text
Text2.ZOrder 1
End If
End Sub
Private Sub Text2_LostFocus()
If UsingMouse = True Then
UsingMouse = False
Exit Sub
End If
If MSFlexGrid1.Col <= MSFlexGrid1.Cols - 2 Then
MSFlexGrid1.Col = MSFlexGrid1.Col + 1
ChangeCellText
Else
If MSFlexGrid1.Row + 1 < MSFlexGrid1.Rows Then
MSFlexGrid1.Row = MSFlexGrid1.Row + 1
MSFlexGrid1.Col = 1
ChangeCellText
End If
End If
End Sub
Public Sub ChangeCellText() ' deplacement Textbox a la cell active.
Text2.Move MSFlexGrid1.Left + MSFlexGrid1.CellLeft, _
MSFlexGrid1.Top + MSFlexGrid1.CellTop, _
MSFlexGrid1.CellWidth, MSFlexGrid1.CellHeight
Text2.SetFocus
Text2.ZOrder 0
End Sub
a+
Jean-Pol DAVID
mailto:david.sa@skynet.be
www.peintures-david.com
ICQ 28394733
--
Quis ? Quid ? Ubi ? Quibus auxiliis ? Cur ? Quomodo ? Quando ?
"Raymond Fournier" <duracelle(Enlever-ceci)@sympatico.ca> a écrit dans le
message de news: Xns95A995DD0DEE7duracelleEnleverceci@207.35.177.135...
Bonjour a tous,
J'utilise un contrôle MSFlexGrid qui lui est dans un contrôle
picture. Je place une boite de texte sur les cellules pour entrer du texte
dans la grille. Je rencontre le problème que ma boute de texte ne commence
pas au début de la cellule mais léger ment en avant. voici le code que
j'utilise pour placer ma boite de texte:
Tout est correct la largeur, la hauteur, le .top mais pas le .left.
Le contrôle picture commence à 0,0 de ma form, ainsi que le MSFlexGrid qui
est à 0,0 du contrôle picture.
Private Sub MSFlexGrid1_DragOver(Source As Control, x As Single, y As Single, State As Integer) PositionCol = MSFlexGrid1.MouseCol PositionRow = MSFlexGrid1.MouseRow Text1 = PositionCol Text3 = PositionRow
If PositionCol = 0 Or PositionRow = 0 Then Source.DragIcon = LoadPicture("C:DaviwebICONEmisc06.ICO") Else 'Source.DragIcon = LoadPicture("C:DaviwebICONEpoint02.ICO") Source.DragIcon = LoadPicture() End If
Select Case State 'Case vbEnter Case vbLeave Text2.Drag (vbCancel) Source.DragIcon = LoadPicture() End Select
End Sub
Private Sub MSFlexGrid1_Scroll() Text2.ZOrder 1 End Sub
Private Sub Text1_LostFocus() MSFlexGrid1.Col = 1 MSFlexGrid1.Row = 1 End Sub
Private Sub Text2_GotFocus() MSFlexGrid1.Text = Text2.Text Text2.SelStart = Len(Text2)
If MSFlexGrid1.Col >= MSFlexGrid1.Cols Then MSFlexGrid1.Col = 1 ChangeCellText End Sub
Private Sub MSFlexGrid1_EnterCell() ' Assigne texte cellule au textbox Text2.Text = MSFlexGrid1.Text End Sub
Private Sub MSFlexGrid1_LeaveCell() ' Assigne textbox value a la grille
MSFlexGrid1.Text = Text2.Text Text2.Text = "" End Sub
Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, _ x As Single, y As Single) posicol = MSFlexGrid1.MouseCol posirow = MSFlexGrid1.MouseRow
UsingMouse = True MSFlexGrid1.Text = Text2.Text ChangeCellText End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then MSFlexGrid1.Text = Text2.Text Text2.ZOrder 1 End If
End Sub
Private Sub Text2_LostFocus() If UsingMouse = True Then UsingMouse = False Exit Sub End If
If MSFlexGrid1.Col <= MSFlexGrid1.Cols - 2 Then MSFlexGrid1.Col = MSFlexGrid1.Col + 1 ChangeCellText Else If MSFlexGrid1.Row + 1 < MSFlexGrid1.Rows Then MSFlexGrid1.Row = MSFlexGrid1.Row + 1 MSFlexGrid1.Col = 1 ChangeCellText End If End If End Sub
Public Sub ChangeCellText() ' deplacement Textbox a la cell active. Text2.Move MSFlexGrid1.Left + MSFlexGrid1.CellLeft, _ MSFlexGrid1.Top + MSFlexGrid1.CellTop, _ MSFlexGrid1.CellWidth, MSFlexGrid1.CellHeight Text2.SetFocus Text2.ZOrder 0 End Sub
a+ Jean-Pol DAVID mailto: www.peintures-david.com ICQ 28394733 -- Quis ? Quid ? Ubi ? Quibus auxiliis ? Cur ? Quomodo ? Quando ? "Raymond Fournier" <duracelle(Enlever-ceci)@sympatico.ca> a écrit dans le message de news:
Bonjour a tous, J'utilise un contrôle MSFlexGrid qui lui est dans un contrôle picture. Je place une boite de texte sur les cellules pour entrer du texte dans la grille. Je rencontre le problème que ma boute de texte ne commence pas au début de la cellule mais léger ment en avant. voici le code que j'utilise pour placer ma boite de texte:
Tout est correct la largeur, la hauteur, le .top mais pas le .left. Le contrôle picture commence à 0,0 de ma form, ainsi que le MSFlexGrid qui est à 0,0 du contrôle picture.