Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

C# Wizard for Beginners

0.00/5 (No votes)
14 Dec 2003 1  
C# Wizard for Beginners

What's new?

Bugs in the installer software have been corrected.

Introduction

This is a wizard for use in the C# environment.

Background

A lot of time is spent in developing simple but time-consuming user interfaces in Visual studio .NET in the C# environment in the initial stages since, Microsoft Corporation has provided only a plain and simple form in the Wizard which is bundled with Visual Studio, you got to add the controls like Toolbar, StatusBar , Menu which are commonly used in most applications. In order to reduce the burden of creating and adding the usual controls I thought of creating a Wizard which would accomplish all these tasks, I managed to complete the Wizard and have been using it for quite sometime now, so I just decided to give it away others who may want to use it. This is especially useful for beginners who may find it difficult to create those Windows Explorer like interfaces. And since the Add Form option in Visual Studio .NET has a similar plain interface I decided to add a Form Designing wizard using this technique.

Features

With this Wizard you can create the following type of user interfaces

  • Plain Form
  • Windows Explorer like interface (vertical)
  • Windows Explorer like interface (horizontal)
  • Windows Explorer like interface (3-Pane)
  • Outlook Express like interface
  • Single Document interface
  • Multi Document interface

The above interfaces can optionally have

  • ToolBar
  • StatusBar
  • MainMenu
  • About Box

In the above interfaces you can select the Control for each pane from a pull-down list and can also set the System Menu, Minimize and Maximize options, you can also set the Maximized or Minimized state of the Window; Initial size of the Window can also be set.

Menu can be the plain menu as provided by C# or can have a Owner-Drawn menu option, read the "Owner-Drawn Menus" section below.

Owner-Drawn Menus

If you select the Owner-Drawn menu option the menu will be drawn using internal code and look a bit different from the usual C# menus. if you created the application by selecting "Owner-Drawn menus" option and at a latter stage want to add new menu items to the menu, to give the newly added menus Owner-Drawn status, do the following.

For each of the newly added menu items set the OwnerDrawn property to true, make Checked and RadioCheck options false (menu items will not be visible if these are set true either at design-time or through code). if you are adding a Separator , do not make its OwnerDrawn property true (I have not found a way out for this). And in the Form1_OnLoad(..) function add the following lines of code.

this.menuItemFile.DrawItem += new System.Windows.Forms.DrawItemEventHandler(
    this.menuItem_DrawItem);
this.menuItemFile.MeasureItem += new System.Windows.Forms.MeasureItemEventHandler(
    this.menuItem_MeasureItem);

Remember to change the name "menuItemFile" above to the name of you MenuItem

If you feel the the owner-drawn option is okay and want to add this to any Context Menus that you plan to add to the application you can use the Owner-Drawn state by following the guidelines for normal menu items above.

Common-Control Manifest

If you check the Common-Control Manifest option on the User-Interface Features page a file named <your-Project-Name>.exe.manifest will be copied in your projects bin\debug folder, when you build and run the project it will have Windows XP Style look. However, for all controls that you will add to the project at a later stage, you must set the FlatStyle property, read the section "About FlatStyle Property".

You have to bundle the manifest file (<your-project>.exe.manifest) along with your applications executable, it must be in the same folder as the applications executable when installing the application at your Client's site

About FlatStyle property

For Controls you add to have a Windows XP like look you have to set the FlatStyle property to System. There is a down-side to this setting, you may not be able to display icons or images on these controls or align Text. Given below is a list of controls, Column "FlatStyle" indicates if this Controls has "FlatStyle" property, Column "Effective" indicates if changing this property has any effect on the control.


Control FlatStyle Effective Control FlatStyle Effective
Label Yes Yes LinkLabel Yes Yes
Button Yes Yes TextBox No Yes
MainMenu No No CheckBox Yes Yes
RadioButton Yes Yes BroupBox Yes Yes
PictureBox No Yes Panel No No
DataGrid No Yes ListBox No Yes
CheckedListBox No Yes ComboBox No Yes
ListView No Yes TreeView No Yes
TabControl No Yes MonthCalendar No Yes
DateTimePicker No Yes HScrollBar No Yes
VScrollBar No Yes Splitter No Yes
DomainUpDown No No NumericUpDown No No
TrackBar No Yes ProgressBar No Yes
RichTextBox No Yes

How to Install

Download the Wizard installer at the top and click on the Install button, if all goes well you can start Visual Studio and you find the icons in the New Project Wizard and Add Form options. This was developed Tested and used on Visual Studio Enterprise edition.

History

  • New Article Release dated 21 - November - 2003.
  • Bugs in Installer corrected

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here