|
-
Dec 5th, 2008, 06:29 PM
#1
Thread Starter
Fanatic Member
[2005] Button Help
Hello sir,
I am having 3 linklabels on the form and 1 button.
Consider these are the linklabels.
a
b
c
When "a" is clicked, button is visible on the form and when i click the button HTML output is displayed (i had already attached HTML pages to my project and also i know how to display output for HTML pages in the project) .
For a,b,c i am having different HTML pages.
What i actually need is?
I want to use only one button. But when i click a,b,c linklabels, the appropriate HTML output must be displayed.
-
Dec 5th, 2008, 07:07 PM
#2
Re: [2005] Button Help
So when you click one of the labels, you need to set some form level variable to indicate which one was pressed. Then the button click event would display the HTML based on the value of that variable.
My usual boring signature: Nothing
 
-
Dec 5th, 2008, 08:27 PM
#3
Thread Starter
Fanatic Member
Re: [2005] Button Help
 Originally Posted by Shaggy Hiker
So when you click one of the labels, you need to set some form level variable to indicate which one was pressed. Then the button click event would display the HTML based on the value of that variable.
Hello sir,
I cant get you sir,
Can u explain me in more detail?
-
Dec 8th, 2008, 07:04 PM
#4
Thread Starter
Fanatic Member
Re: [2005] Button Help
Hello sir,
How to set form level variables to detect which button is pressed?
-
Dec 9th, 2008, 09:42 AM
#5
PowerPoster
Re: [2005] Button Help
 Originally Posted by bharanidharanit
Hello sir,
How to set form level variables to detect which button is pressed?
you would create a public variable at the top of the code page. something like
Public MyVariableName as integer = 0
then in the relevant event for the link label, you would do something like:
of course, the value of MyVariableName would be different for each, eg:
MyVariableName = 1
MyVariableName = 2
MyVariableName = 3
then you would check the value of MyVariableName and do what you want accordingly. eg:
Select Case MyVariableName
Case 1
'do something for MyVariableName = 1
Case 2
'do something for MyVariableName = 2
Case Else
'do something for MyVariableName when its not = 1 or = 2
End Select
of course, i used an integer but you can use any data type, i suppose
Last edited by BrailleSchool; Dec 9th, 2008 at 09:49 AM.
-
Dec 9th, 2008, 09:51 AM
#6
Fanatic Member
Re: [2005] Button Help
You can also set the .Tag property on the Button then display the HTML based on the .Tag Property.
Code:
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
Button1.Tag = "a"
End Sub
Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
Button1.Tag = "b"
End Sub
Private Sub LinkLabel3_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel3.LinkClicked
Button1.Tag = "c"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Button1.Tag IsNot Nothing Then
Select Case Button1.Tag.ToString
Case "a"
'Show HTML for a
Case "b"
'Show HTML for b
Case "c"
'Show HTML for c
Case Else
MessageBox.Show("Not a valid selection")
End Select
End If
End Sub
The way they were describing in previous posts on using a form level variable is something similar to what is above, see below:
Code:
Public Class Form1
Private LabelClicked As String = "a"
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
LabelClicked = "a"
End Sub
Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
LabelClicked = "b"
End Sub
Private Sub LinkLabel3_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel3.LinkClicked
LabelClicked = "c"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Select Case LabelClicked
Case "a"
'Show HTML for a
Case "b"
'Show HTML for b
Case "c"
'Show HTML for c
Case Else
MessageBox.Show("Not a valid selection")
End Select
End Sub
End Class
Either way the result is the same. I hope this helps you some!
Good Luck!
D
Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP
Please Rate If I helped you. 
Please remember to mark threads as closed if your issue has been resolved.
Reserved Words in Access | Connection Strings
-
Dec 9th, 2008, 08:13 PM
#7
Thread Starter
Fanatic Member
Re: [2005] Button Help
 Originally Posted by dminder
You can also set the .Tag property on the Button then display the HTML based on the .Tag Property.
Code:
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
Button1.Tag = "a"
End Sub
Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
Button1.Tag = "b"
End Sub
Private Sub LinkLabel3_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel3.LinkClicked
Button1.Tag = "c"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Button1.Tag IsNot Nothing Then
Select Case Button1.Tag.ToString
Case "a"
'Show HTML for a
Case "b"
'Show HTML for b
Case "c"
'Show HTML for c
Case Else
MessageBox.Show("Not a valid selection")
End Select
End If
End Sub
The way they were describing in previous posts on using a form level variable is something similar to what is above, see below:
Code:
Public Class Form1
Private LabelClicked As String = "a"
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
LabelClicked = "a"
End Sub
Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
LabelClicked = "b"
End Sub
Private Sub LinkLabel3_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel3.LinkClicked
LabelClicked = "c"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Select Case LabelClicked
Case "a"
'Show HTML for a
Case "b"
'Show HTML for b
Case "c"
'Show HTML for c
Case Else
MessageBox.Show("Not a valid selection")
End Select
End Sub
End Class
Either way the result is the same. I hope this helps you some!
Good Luck!
D
Thankyou sir,
But i am having nearly 1000 of linklabels. Then the coding is some tough. Is there any other possible easy way to do this?
-
Dec 10th, 2008, 04:28 AM
#8
Addicted Member
Re: [2005] Button Help
1000? Isn't that a bit too much to fit on one form? But if you are, are you going to be creating them manually or using some piece of code to generate them when the form loads?
-
Dec 10th, 2008, 08:13 AM
#9
Fanatic Member
Re: [2005] Button Help
Well to do what you described in the original post those are your best 2 options. Regardless if it is 1, 10 or 1000, you will still have to do the same thing - welcome to our world!!
D
Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP
Please Rate If I helped you. 
Please remember to mark threads as closed if your issue has been resolved.
Reserved Words in Access | Connection Strings
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|