NCSO
asked on
Change Label text with click events
Experts,
I have a label (label1) on my form and its text value is “View Details”. What I would like to do is if the user clicks on the view details label; one, change the label1.text value to “Hide Details” and show groupbox1; secondly, if the user now clicks on the label1.text value of “ Hide Details”, make groupbox1.visibility = false and label1.text value back to “View Details”
I currently have the following code but I can not figure out how to make the next click event revert back to the original of groupbox1.visible = false and label1.text = “View Details”
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
GroupBox1.Visible = True
Label1.Text = "Hide Details"
End Sub
Thanks in advance
I have a label (label1) on my form and its text value is “View Details”. What I would like to do is if the user clicks on the view details label; one, change the label1.text value to “Hide Details” and show groupbox1; secondly, if the user now clicks on the label1.text value of “ Hide Details”, make groupbox1.visibility = false and label1.text value back to “View Details”
I currently have the following code but I can not figure out how to make the next click event revert back to the original of groupbox1.visible = false and label1.text = “View Details”
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
GroupBox1.Visible = True
Label1.Text = "Hide Details"
End Sub
Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
emoreau,
It works, Kinda!
I click view details and groupbox is visible and the label text changes to hide details
I now click on Hide details and the groupbox is not visible and the text changes to Show, not show details
It works, Kinda!
I click view details and groupbox is visible and the label text changes to hide details
I now click on Hide details and the groupbox is not visible and the text changes to Show, not show details
>>and the text changes to Show, not show details
is your label large enough ?
is your label large enough ?
ASKER
Hit MN,
Same problem with yours
Same problem with yours
ASKER
yes, if I change the text to showdetails with no space I see it
I have tried Label1.Text = "show" + " " + "Details" No luck either
I have tried Label1.Text = "show" + " " + "Details" No luck either
your label is definetly not large enough
can you paste you code please?
can you paste you code please?
ASKER
How is the space between the show and the details making the details section not visible? I want to clarify my earlier statement, if I change the text to label1.text="ShowDetails" I get ShowDetails, not the desired Show Details
Well... set label1.AutoSize = True at design time...
ASKER
BINGO, label not big enough
ASKER
Great Job! Thanks for you assistance. "Hit MN", you were also correct. However "emoreau" declared first with same solution
I agree with emoreau post (so, no points to me... :D ), but I would do it like this:
If GroupBox1.Visible = True Then
GroupBox1.Visible = False
Label1.Text = "Show Details"
Else
GroupBox1.Visible = True
Label1.Text = "Hide Details"
End If
HTH,
Marco