|
The Form design, Mainform
Rename
the Form Form1.cs created and add new controls to it
- (New name - MainForm)
Classes used in this Form:
MainMenu, Timer, PictureBox, Label and
StausBar
1- Rename
the Form
- On the View
menu , click Solution
Explorer
- In Solution
Explorer, expand the App_CAKJV10
project node and select
Form1.cs
- In
Properties windows, Type the new
File Name
|
Old |
New |
Filename : |
Form1.cs |
MainForm.cs | | |
|
1- Modify the Form Properties
...
- On the View
menu , click Solution
Explorer
- In Solution
Explorer, expand the App_CAKJV10
project node
- Right click the
MainForm.cs and click
View Designer on the shortcut
menu to open the Properties
Windows.
- In
Properties windows, modify
...
|
Old |
New |
Name: FormBorderStyle Icon: Menu: Size: Text: Window
State: |
Form1 Sizable Icon (none) 300,300 Form1 Normal |
MainForm FixedSingle Icon
mainMenu1 630,500 Main
Form
... Maximized | | | |
- On the Project
menu , click App_CAKJV10 Properties ...,
the App_CAKJV10 Property Pages dialog box
appears
- In the Startup
object combo box, choose and select
MainForm
- Click OK
|
Create new Folder
- On the View
menu , click Solution
Explorer
- In Solution
Explorer, expand the App_CAKJV10
project node, click Right mouse
Button, click Add of the
Popup menu, and the click New Folder
- New Folder
appears in the Solution Explorer.
Rename it - Pic
|
copy
Files ...
- From the folder
Pic of the File
download, copy all files ( picture
files and KJV2002.mdb) to the folder -
C:\App_CAKJV10/App_CAKJV10
- On the
Projet menu , click Add
Existing Item ..., Add Existing
Item - App_CAKJV10 dialog box
appears, select the files ingraphic1.bmp and
App-VCSNet.ico of the folder
c:\App_CAKJV10/App_CAKJV10/Pic, and then click
Open.
| |
1- |
The MainForm.cs
design |
|
 |
2- |
From the Toolbox/Windows Form add these
controls ...
|
|
- Add
the PictureBox
control - PictureBox1,
PictureBox
Properties:
Name: Image: Size
Mode: |
PictureBox1 System.Drawing.Bitmap Autosize | |
Bitmap file
added =
C:\App_CAKJV10/App_CAKJV10/Pic\ingraphic1.bmp
- Add
the Label
control
- Label1, Label
Properties:
Font: Name: Size: Text: TextAlign: |
Times New Roman, 9.75pt,
style=Bold,
Italic Label1: 360,16 Learn
how to write Microsoft
Visual C# 2010
application
... MiddleCenter | |
- Add
the StatusBar
control - StatusBar1,
StatusBar
Properties:
Name: Panels: Show
Panels: Size: Text: |
StatusBar1 (collection) True 804,16 StatusBar1 | |
The
StatusBarPanel Collection
Editor dialog box stores
info about the panels added to this
control. StatusBarPanel
Properties ....
Name |
Alignment |
AutoSize |
Text |
ToolTipText |
Width |
StatusBarPanel1 StatusBarPanel2 StatusBarPanel3 |
left center center |
None Spring Spring |
none - - |
Status... Date
... Time ... |
200 200
200 | |
- Add
the Timer
control
- Timer1,
Timer Properties:
Name: Enabled: Interval: |
Timer1 True 100 | |
- Add the
MainMenu control,
MainMenu1
The
MainMenu control represents the container for
the menu structure of a form.
A menu is composed of
MenuItem objects that represent the individual menu
commands in the menu structure.
Each MenuItem can be
a command for your application or a parent menu
for other submenu
items.
Add to this menu - MainMenu1 the
following items
menu
Item |
Name |
Text |
0 1 2 3 4 5 |
MenuItem1 MenuItem2 MenuItem3 MenuItem4 MenuItem5 MenuItem6 |
Info
Menu Book - About - Exit |
The menu
design
...
| | | |
|
How
create Public Event in Visual C# 2010
MainForm.cs file, the
code ... |
|
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using System.Data;
using
System.Drawing;
using System.Linq;
using System.Text;
using
System.Windows.Forms;
namespace
App_CAKJV10
{
public
partial
class
MainForm
:
Form
{
public MainForm()
{
InitializeComponent();
}
private
void
MainForm_Load(object
sender,
EventArgs
e)
{
// Resize ...
// PictureBox control
this.pictureBox1.Left
= ((this.Width
-
this.pictureBox1.Width)
/ 2);
this.pictureBox1.Top
=
this.Height / 4;
// Label control
this.label1.Width =
this.Width
- 100;
this.label1.Left = (this.Width
-
this.label1.Width) /
2;
this.label1.Top =
this.Height
* 3 / 4;
this.statusBarPanel1.Width
= (this.Width
* 3) / 8;
this.statusBarPanel2.Width
=
this.Width * 3 / 8;
this.statusBarPanel3.Width
=
this.Width * 2 / 8;
// StatusBar Panel 1, Message ...
this.statusBarPanel1.Text
=
"Hello ...";
// StatusBarPanel2, Date ...
this.statusBarPanel2.Text
=
DateTime.Now.ToLongDateString();
// StatusBarPanel3, Time ...
this.statusBarPanel3.Text
=
DateTime.Now.ToShortTimeString();
}
private
void
menuItem2_Click(object
sender,
EventArgs
e)
{
BookForm Fbook =
new
BookForm();
// StatusBar Panel 1 = Message
this.statusBarPanel1.Text
=
"Book Form, moment ...";
Fbook.Show();
this.statusBarPanel1.Text
=
"Ready Book Form ...";
}
private
void
menuItem4_Click(object
sender,
EventArgs
e)
{
About Fabout =
new
About();
// StatusBar Panel 1 = Message
this.statusBarPanel1.Text
=
"About Form, moment ...";
Fabout.Show();
this.statusBarPanel1.Text
=
"Ready About Form ...";
}
private
void
menuItem6_Click(object
sender,
EventArgs
e)
{
Application.Exit();
}
private
void
timer1_Tick(object
sender,
EventArgs
e)
{
// StatusBarPanel3, Time ...
this.statusBarPanel3.Text
=
DateTime.Now.ToLongTimeString();
}
private
void
MainForm_FormClosing(object
sender,
FormClosingEventArgs
e)
{
Application.Exit();
}
private
void
menuItem8_Click(object
sender,
EventArgs
e)
{
Biography FBiography
=
new
Biography();
// StatusBar Panel 1 = Message
this.statusBarPanel1.Text
=
"Biography Form, moment ...";
FBiography.Show();
this.statusBarPanel1.Text
=
"Ready Biography Form ...";
}
}
}
| | |
|
|