Exercise 2: Create Dialog Box: Difference between revisions

From AutoCount Resource Center
Content added Content deleted
mNo edit summary
Line 86: Line 86:


==See Also==
==See Also==
* [[Plug-In 1.8 Getting Started]]
* [[Plug-In 1.8 User Control & Interface]]
* [[Exercise_1:_Build_My_First_Plug-In|Exercise 1: Build My First Plug-In]]
* [[Exercise_1:_Build_My_First_Plug-In|Exercise 1: Build My First Plug-In]]
* [[Exercise_2:_Create_Dialog_Box|Exercise 2: Create Dialog Box]]
* [[Exercise_3:_Create_Form|Exercise 3: Create Form]]
* [[Exercise_3:_Create_Form|Exercise 3: Create Form]]
* [[Exercise 4: Design Form of AutoCount Accounting 1.8]]
* [[Exercise 5: Design Grid of AutoCount Accounting 1.8]]


[[Category:Programmer]]
[[Category:Programmer]]

Revision as of 06:22, 2 January 2018

Go to menu

Go to top
Resources For AutoCount Software Developers


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

[Properties]
Text = "About"

6. Add a Label onto FormAbout at Form Design

[Properties]
(Name) = lblAbout
Text = "Plug-in Tutorial : Getting Started version 1.0.2"

7. Add a button

[Properties]
(Name) = btnOK
Text = &OK

8. Make “About” form appear at the menu.

  • Declare the attribute class, using BCE.AutoCount.PlugIn.MenuItem
  • Define 1 parameter, and 3 optional parameters
    1. Menu Caption = "About"
    2. BeginNewGroup = true
      (Draw a line one top of this menu)
    3. MenuOrder = 99
      (Set this menu item at bottom)
    4. 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