Exercise 2: Create Dialog Box
Objectives: Create an “About” Dialog Box to display information of this plug-in. This exercise shows the steps to create Dialog Box using Class Attributes.
1. Open the Plug-in project “Tutorial.PRG201” from Exercise 1.
2. Amend the plug-in version to “1.0.2”
3. Right-Click on “Tutorial.PRG201” (Project),
- Select -> Add | Windows Forms…
4. Type the form name as “FormAbout.cs”
5. Edit the Form Text
6. Add a Label onto FormAbout at Form Design
7. Add a button
|
8. Make “About” form appear at the menu.
- Declare the attribute class, using BCE.AutoCount.PlugIn.MenuItem
- Define 1 parameter, and 3 optional parameters
- Menu Caption = "About"
- BeginNewGroup = true
(Draw a line one top of this menu) - MenuOrder = 99
(Set this menu item at bottom) - ShowAsDialog = true
(Form will not be maximized)
9. Constructor of MenuItem requires one argument
- Insert “BCE.Data.DBSetting dbSetting” in the constructor.
[BCE.AutoCount.PlugIn.MenuItem("About", BeginNewGroup = true, MenuOrder = 99, ShowAsDialog = true)]
public partial class FormAbout : Form
{
public FormAbout(BCE.Data.DBSetting dbSetting)
{
InitializeComponent();
}
}
10. Add below statements into the constructor, which changes FormAbout properties.
11. Add Button [OK] event
- At the “FormAbout” Design, double clicks the button [OK].
- Insert “Close()” in the click event.
public FormAbout(BCE.Data.DBSetting dbSetting)
{
InitializeComponent();
StartPosition = FormStartPosition.CenterScreen;
FormBorderStyle = FormBorderStyle.FixedDialog;
MaximizeBox = false;
MinimizeBox = false;
}
private void btnOK_Click(object sender, EventArgs e)
{
Close();
}
See Also
Go to top
|
Resources For AutoCount Software Developers
|