neurosupherot
Messages postés81Date d'inscriptionjeudi 7 août 2003StatutMembreDernière intervention 7 novembre 2007
-
15 mars 2005 à 23:11
crenaud76
Messages postés4172Date d'inscriptionmercredi 30 juillet 2003StatutMembreDernière intervention 9 juin 2006
-
6 janv. 2006 à 16:35
Bonjour les VB programmeurs!
je voudrai savoir comment vérifier que le focus est bien sur ce que'on désire
je cherche un truc du genre soit:
Private Sub text1_Setfocus()
ou
If text1.setfocus=true then...
mais aucun des deux ne marche...
comment faut il faire pour vérifier le focus d"un composant quoi...
ou sinon pr les textbox?
au lieu du setfocus n'y a t il pas un if text1.writting then...
cs_rene38
Messages postés1858Date d'inscriptionsamedi 29 juin 2002StatutMembreDernière intervention17 octobre 201311 16 mars 2005 à 09:54
Bonjour
GotFocus, événement
Se produit lorsqu'un objet reçoit le
<OBJECT id=alink_4 type=application/x-oleobject classid=clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11></OBJECT> focus (devient actif) soit à la suite d'une action de l'utilisateur (lorsqu'il utilise la touche <SMALL>tab</SMALL> pour atteindre un objet ou qu'il clique dessus), soit parce que le focus a été modifié dans le code à l'aide de la méthode SetFocus. Une feuille ne reçoit le focus que lorsque tous les contrôles visibles sont désactivés.
Syntaxe :
Private Sub Text1_GotFocus()
crenaud76
Messages postés4172Date d'inscriptionmercredi 30 juillet 2003StatutMembreDernière intervention 9 juin 200628 16 mars 2005 à 11:27
La propriété ActiveControl d'une form te retourne le controle qui à le focus. Donc pour vérifier que TextBox1 a bien le focus ...
If MaForm.ActiveControl.Name = "TextBox1" Then
' Le focus est bien sur TextBox1
Else
' Le focus n'est pas sur TextBox1
Endif
micmerle
Messages postés32Date d'inscriptionmercredi 24 mars 2004StatutMembreDernière intervention 3 août 2006 6 janv. 2006 à 14:45
Hello,
Suis débutant VBA et j'ai un prob dans mon code. Je pensais que c'était du focus mais après essai avec le GotFocus, c'est appremment pas ca. Mais alors quoi?
En fait la procédure ci-dessous est appelée à chaque worksheet_selectionChange pour activiter/désactiver certains menus. Et quand je modifie le .enabled d'un commandButton, ben le menu déroulant de cell n'a plus "copier" activé.
Je veux dire que: je peux copier une cellule mais qd je clique droit sur une autre cellule, le menu "coller" (et "coller spécial") est désactivé. Super embetant. Je peux néanmoins coller à partir du presse-papier.
Vous avez une piste pour moi?
Merci
Michael
Sub EnableDisableStartStopCommands(ByRef rng As Range)
Dim element As Variant
Dim action As String
Dim productId As String
Dim minRow As Integer
Dim currentRow As Integer
Dim selectionStopped As Boolean
Dim oneSelectionStarted As Boolean
Dim oneAutomatonSelected As Boolean
On Error GoTo EnableDisableStartStopCommands_Error
If rng.rows.Count > 30000 Then
oneSelectionStarted = False
GoTo StartAndStopSpecified
End If
minRow = [rngBizHeaders].Row
'get the status of the selection
selectionStopped = True
oneSelectionStarted = False
oneAutomatonSelected = False
' If DictHeader Is Nothing Then
' If Not CreateColHeadersDictionary(DictHeader, Range([rngTechnicalHeaders], [rngTechnicalHeaders].End(xlToRight))) Then
' ShowError "Cannot Build Instrument Headers Dictionary" & " in procedure StartSelectedAutomatons of Module HSA_Controller"
' GoTo exitHere
' End If
' End If
' With TestMarket
' For Each element In rng.rows
' currentRow = element.Row
' action = .Cells(currentRow, CInt(DictHeader(ACTION_FIELD))).Value2
' productId = .Cells(currentRow, CInt(DictHeader(PRODUCTID_FIELD))).Value2
'
' If productId <> vbNullString And currentRow > minRow Then oneAutomatonSelected = True
' If action <> vbNullString And action <> REJECTED_ACTION Then
' selectionStopped = False
' If action <> DELETED_ACTION And action <> DISCONNECTED_ACTION Then oneSelectionStarted = True
' End If
' Next
' End With
StartAndStopSpecified:
If Not oneAutomatonSelected Then
selectionStopped = False
oneSelectionStarted = False
End If
'enable.disable start/stop command buttons
With TestMarket
.CmdStartSelectedAutomatons.Enabled = selectionStopped
.CmdStopSelectedAutomatons.Enabled = oneSelectionStarted
End With
'enable.disable start/stop on rightclick
With Application
.CommandBars("Cell").Controls(STOP_MENU_NAME).Enabled = oneSelectionStarted
.CommandBars("Cell").Controls(START_MENU_NAME).Enabled = selectionStopped
End With
'get the focus back on the selection
TestMarket.Range(rng.Address).Select
TestMarket.Activate