I have a C# form application, in that I have a menu where one of the item is help
. It has a sub-item About
. As you seen in many applications when you click on help a separate dialog box opens up which displays the information.
I want something like that.
To create a new dialog box In Resource View, right-click your . rc file and select Add Resource. In the Add Resource dialog box, select Dialog in the Resource Type list, then choose New. If a plus sign (+) appears next to the Dialog resource type, it means that dialog box templates are available.
They are the grey windows that pop up on Windows systems to display messages, and allow the user to set parameters. There are 3 types of dialog boxes: modeless, modal, and system modal.
A dialog box is a temporary window an application creates to retrieve user input. An application typically uses dialog boxes to prompt the user for additional information for menu items.
Looks like you have not been searching for long, here it goes just add one using predefined template:
And you could possibly find this link useful:
social.msdn.microsoft.com
Quote from there:
- Create a new windows form application
- In the "Solution explorer" ,left part of the screen , right click on the name of your windows application.
- Choose Add-->New item
- From the " Add new item window" choose "AboutBox" , name it "AboutBox1" , click on Add button. Now you have in your applicatoin two forms, "Form1" -- created by default by your project type and "AboutBox1" .
- Right click on the "Form1" and choose "Design View".
- Double click on the design sourface of form1.
After that you will see this code:
private void Form1_Load(object sender, EventArgs e) { }
Add this code to your application, to look like this:
private void Form1_Load(object sender, EventArgs e) { AboutBox1 a = new AboutBox1(); a.Show(); }
Run the application.
To add a menu to a Windows Form at design time Open the form you wish to add a menu to in the Windows Forms Designer.
double-click
the MenuStrip
component.Then you can do that as follows using click Event of that particuler subMenu item .
Hint:Just click the subMenu item and rightclick->Properties
..then you can find the Click Event
for subMenuItem
.
private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
{
AboutWindow aboutWindow = new AboutWindow();
aboutWindow.Show();
}
There is a standard about box in the templates, try Project / Add new item and look for About Box. You can show it like a regular dialog form, e.g. using new AboutBox(this). ShowDialog(); in the menu item click handler.
Before or after adding About Box to the project from the list of possible items, make sure that AssemblyInfo.cs is fulfilled with data.
AssemblyInfo.cs in Solution Explorer Window
In your project, click on Properties. Open AssemblyInfo.cs. This is the source of the info displayed in About Box.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With