MnInShdw
asked on
Get Lable Name
It may be a wierd question, but please bear with me.
Me.name returns the active form name.
Is there any method or function that can return the current label/button name?
msgbox Me.Name in the onclick action of a form, will show a messagebox with the name of the form .
Is it possible to have the same thing for a Button or a Label. (a messagebox with the clicked button/lable).
Imagine I have 2 Labels in a form and a user clicks one of them.
is there any way to find out which one of these labels are clicked?
thank you
Me.name returns the active form name.
Is there any method or function that can return the current label/button name?
msgbox Me.Name in the onclick action of a form, will show a messagebox with the name of the form .
Is it possible to have the same thing for a Button or a Label. (a messagebox with the clicked button/lable).
Imagine I have 2 Labels in a form and a user clicks one of them.
is there any way to find out which one of these labels are clicked?
thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Screen.ActiveControl.Name doesn't work for labels because
Labels can't accept the focus.
thank you
Labels can't accept the focus.
thank you
Upon reading your question, I knew that a label could not accept focus and will therefore never be the currently active control!
I thought you had mistyped the question, so sorry for the confusion.
I thought you had mistyped the question, so sorry for the confusion.
ASKER
Private Sub label_MouseClick(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles Label2.MouseClick, Label1.MouseClick
Dim control As Control = CType(sender, Control)
MessageBox.Show(control.Name)
End Sub
Sorry, but I have to admit I can't understand what you mean.
where this sub should be added?
And how I can run this sub?
As far as I know up to Access 2010, OnClick action for controls of a from is written something like
Private Sub labelname_Click()
and it doesn't receive any parameters.
my bad, sorry
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Million thanks for your help
Open in new window
Hope it helps