01.
ublic partial
class
FormMain : Form
02.
{
03.
private
FormStore formStore =
new
FormStore();
04.
05.
public
FormMain()
06.
{
07.
InitializeComponent();
08.
}
09.
10.
private
void
FormMain_Load(
object
sender, EventArgs e)
11.
{
12.
this
.Width = 1200;
13.
this
.Height = 750;
14.
this
.Left = (
int
)(Screen.PrimaryScreen.Bounds.Width / 2) - (
int
)(
this
.Width / 2);
15.
this
.Top = 5;
16.
}
17.
18.
private
void
toolStrip1_ItemClicked(
object
sender, ToolStripItemClickedEventArgs e)
19.
{
20.
string
txt = e.ClickedItem.Text;
21.
switch
(txt)
22.
{
23.
case
"รายการสินค้า"
:
24.
{
25.
ShowChildForm(formStore);
26.
}
27.
break
;
28.
}
29.
}
30.
private
void
ShowChildForm(Form f)
31.
{
32.
if
(f.Visible ==
true
)
33.
{
34.
f.BringToFront();
35.
}
36.
else
37.
{
38.
f.MdiParent =
this
;
39.
f.Show();
40.
}
41.
}
42.
43.
private
void
FormMain_MdiChildActivate(
object
sender, EventArgs e)
44.
{
45.
if
(
this
.ActiveMdiChild ==
null
)
46.
{
47.
return
;
48.
}
49.
else
50.
{
51.
toolStripStatusLabel1.Text =
this
.ActiveMdiChild.Text;
52.
}
53.
}
54.
}