This message was discovered on ASPFriends.com 'winforms-cs' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
| Steven A Smith (VIP) |
I have a MainMenu on a form, and it has a Help --> About MenuItem. I'd like the click event for this to bring up my About form. How do I do that in .NET?
Steve
Steven Smith, MCSE+Internet, Microsoft MVP: ASP.NET Click here to reveal e-mail address President, ASPAlliance.com http://aspalliance.com The #1 ASP.NET Community http://aspsmith.com ASP.NET Training for ASP Developers
Learning ASP.NET? Get My Book: ASP.NET By Example http://amazon.com/exec/obidos/ASIN/0789725622/stevenatorasp/
|
|
| |
| |
| Ryan Trudelle-Schwarz |
Which part are you unsure about?
To delegate a method as an event handler for the click event of the = about menu item, specify it in the system.windows.forms.menuitem = constructor.
To show a menu you can do it a few different ways. Easiest ways I know = of are to use the ShowDialog methods of the forms.
-----Original Message----- From: Steven A Smith [mailto:Click here to reveal e-mail address]=20
I have a MainMenu on a form, and it has a Help --> About MenuItem. = I'd like the click event for this to bring up my About form. How do I = do that in .NET? =20 Steve =20
Steven Smith, MCSE+Internet, Microsoft MVP: ASP.NET =20
--- [This E-mail scanned for viruses by Declude Virus]
|
|
| |
|
| | |
| |
| Steven A Smith (VIP) |
I think this is what I need, thanks. I didn't realize I had to instantiate a reference to my About form - I figured all the forms were loaded with the application.
Steve
----- Original Message ----- From: Per Erik Lorentzen To: winforms-cs Sent: Tuesday, May 14, 2002 3:57 AM Subject: [winforms-cs] Re: Simple Question
private void mnuAbout_Click(object sender, System.EventArgs e)
{
using (frmAbout frmAbout = new frmAbout())
{
frmAbout.ShowDialog();
}
}
Here, the name of the About form / class must be frmAbout.cs. With the using () you're sure the object is disposed after the dialog is closed.
Med hilsen Per Erik Lorentzen SK Data as Click here to reveal e-mail address ----- Original Message ----- From: Steven A Smith To: winforms-cs Sent: Tuesday, May 14, 2002 7:59 AM Subject: [winforms-cs] Simple Question
I have a MainMenu on a form, and it has a Help --> About MenuItem. I'd like the click event for this to bring up my About form. How do I do that in .NET?
Steve
Steven Smith, MCSE+Internet, Microsoft MVP: ASP.NET Click here to reveal e-mail address President, ASPAlliance.com http://aspalliance.com The #1 ASP.NET Community http://aspsmith.com ASP.NET Training for ASP Developers
Learning ASP.NET? Get My Book: ASP.NET By Example http://amazon.com/exec/obidos/ASIN/0789725622/stevenatorasp/ | [winforms-cs] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/winforms-cs.asp = JOIN/QUIT | [winforms-cs] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/winforms-cs.asp = JOIN/QUIT
|
|
| |
|
| |
| Steven A Smith (VIP) |
Next question - I have a LinkLabel which has a URL as its text. I don't see where to specify the target URL for the link, and although it has a Click event handler, I don't know how to tell it to upen up a URL in a browser. I kinda figured it would do that for me as a built-in behavior, but clicking on does absolutely nothing at the moment.
Steve
|
|
| |
|
| |
| Ryan Trudelle-Schwarz |
There=E2=80=99s a nice bit in the SDK about it.
Basically, you add a link to the Links collection (a property of the = linklabel) and subscribe to the LinkClicked event. Your event handler can then use the Link property of the event arguments = to determine which link was clicked and act accordingly.
Hth, Ryan
-----Original Message----- From: Steven A Smith [mailto:Click here to reveal e-mail address]=20
Next question - I have a LinkLabel which has a URL as its text. I don't = see where to specify the target URL for the link, and although it has a = Click event handler, I don't know how to tell it to upen up a URL in a = browser. I kinda figured it would do that for me as a built-in = behavior, but clicking on does absolutely nothing at the moment. =20 Steve =20
--- [This E-mail scanned for viruses by Declude Virus]
|
|
| |
|
| |
| Seth Grossman |
Steven-
There is a topic that covers this in the VS docs - "Linking to an Object or Web Page with the Windows Forms LinkLabel Control"=20
URL within MSDN: ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vbconLinkingToObjectOrWebPageWith LinkLabelControl.htm
net URL: http://msdn.microsoft.com/library/?url=3D/library/en-us/vbcon/html/vbconL= i nkingToObjectOrWebPageWithLinkLabelControl.asp?frame=3Dtrue
However, the code sample in the RTM version of the topic doesn't handle exceptions well. Here is the latest code sample, that handles exceptions better:
private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { try { VisitLink(); } catch (Exception ex ) { MessageBox.Show("Unable to open link that was clicked."); } }
private void VisitLink() { // Change the color of the link text by setting LinkVisited=20 // to true. linkLabel1.LinkVisited =3D true; //Call the Process.Start method to open the default browser=20 //with a URL: System.Diagnostics.Process.Start("http://www.microsoft.com"); }
Thanks Seth Grossman Microsoft Corp. This posting is provided "AS IS" with no warranties, and confers no rights.
-----Original Message----- From: Steven A Smith [mailto:Click here to reveal e-mail address]=20 Sent: Tuesday, May 14, 2002 4:51 PM To: winforms-cs Subject: [winforms-cs] Re: Simple Question
Next question - I have a LinkLabel which has a URL as its text. I don't see where to specify the target URL for the link, and although it has a Click event handler, I don't know how to tell it to upen up a URL in a browser. I kinda figured it would do that for me as a built-in behavior, but clicking on does absolutely nothing at the moment.
Steve
| [winforms-cs] member Click here to reveal e-mail address =3D YOUR ID | http://www.asplists.com/asplists/winforms-cs.asp =3D JOIN/QUIT=20
|
|
| |
|
| |
| Per Erik Lorentzen |
Here's code to send a mail via a linkLabel, using the linkLabel.Text property as the mail-address: private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
try
{
VisitLink(linkLabel1.Text);
}
catch
{
MessageBox.Show("Unable to open link that was clicked.");
}
}
private void VisitLink(string myLink)
{
// Set LinkVisited to true
linkLabel1.LinkVisited = true;
// Create a ProcessStartInfo object, and set the properties
System.Diagnostics.ProcessStartInfo myProcess = new System.Diagnostics.ProcessStartInfo();
myProcess.CreateNoWindow = false;
myProcess.FileName = @"mailto:" + myLink;
// Start the process
System.Diagnostics.Process.Start(myProcess);
}
Now, if you'd like to open an URL, just remove the "mailto:" prefix...
Med hilsen Per Erik Lorentzen SK Data as Click here to reveal e-mail address ----- Original Message ----- From: Steven A Smith To: winforms-cs Sent: Wednesday, May 15, 2002 1:50 AM Subject: [winforms-cs] Re: Simple Question
Next question - I have a LinkLabel which has a URL as its text. I don't see where to specify the target URL for the link, and although it has a Click event handler, I don't know how to tell it to upen up a URL in a browser. I kinda figured it would do that for me as a built-in behavior, but clicking on does absolutely nothing at the moment.
Steve
| [winforms-cs] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/winforms-cs.asp = JOIN/QUIT
|
|
| |
|
|
|
|
|