|
The
Form design, agenda_task.cs
Create Visual C# 2010 Forn -
agenda_task.cs
Classes used in this
Form:
PictureBox,
RadioButton, Button, ImageList, TextBox, Label,
GroupBox
Create the Form
agenda_task.cs
Add New Item -
agenda_task.cs Form to work_VCNet10
Project
- On the Projet
menu , click Add New Item ...,
Add New Item - work_VCNet10 dialog box appears, Select
Windows form Icon,
in the Name box type
agenda_task.cs and then click
Add.
|
 |
|
Note:
In the Windows Forms Designer appears the
design form created and in the Properties
Windows displays the corresponding properties
and
The design Form agenda_task.cs created, appears the empty window Form
design |
|
The codes file, created
... |
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
work_VCNet10
{
public
partial
class
agenda_task :
Form
{
public
agenda_task()
{
InitializeComponent();
}
private
void agenda_task_Load(object
sender,
EventArgs
e)
{
}
}
}
|
|
|
|
|
1. |
Picture files used by this form ...
|
|
- The folder
c:\work_VCNet10\work_VCNet10\pic stored the
bmp files p_high.bmp,
p_low.bmp, p_normal.bmp,
btn_cancel.bmp,
btn_ok.bmp
|
2. |
The
agenda_task.cs design |
|
 |
The Properties of
the Form -
agenda_task.cs... |
Name: Icon: Maximize: Menu: Size: Start
Position: Text: Window
State: |
agenda_task Icon False (none) 368,332 CenterScreen agenda_task
... Normal | | | |
3. |
From the Toolbox/Windows Form add these
controls . .3 PictureBox controls, 1 GroupBox
control, 3 RadioButton controls, 2
Button controls, 1 ImageList
control, 1 TextBox control, 1
Label control |
|
- Add
t3 PictureBox
control
- PicA1,
PictureBox
Properties
Name: Image: Size
Mode: |
Picico System.Drawing.Bitmap Autosize | |
Bitmap
file added = C:\work_VCNet10\work_VCNet10\pic\p_high.bmp
- PicA2 -
Bitmap
file added = C:\work_VCNet10\work_VCNet10\pic\p_low.bmp
- Pic\A3
-
Bitmap file added = C:\work_VCNet10\work_VCNet10\pic\p_normal.bmp
|
- Add
the GroupBox
control - GroupBox1
Properties:
Name: Size: Text: |
GroupBox1 104, 84 task
prirority | |
- Add
2
RadioButton
controls
- rad_ligh,
RadioButton
Properties
- rad_low
Text:
low
- rad_normal
Text:
normal
|
- Add
the Button
control
- btn_ok, Button
Properties
Name: ImageIndex: ImageList: Size: Text: |
btn_ok 0 ImageList1 65,24 | |
- btn_cancel
ImageIndex:
1
|
- Add
the ImageList
control
-
ImageList1, ImageList
Properties:
Name: Images: ImageSize: |
ImageList1 (Collection)
- of 2
Bitmap
images 56,
36 | |
The
folder
c:\work_VCNet10\work_VCNet10\pic stored the
2 bmp files
btn_cancel.bmp,
btn_ok.bmp
- Add
the TextBox
control
- txtdescription,
TextBox Properties
Name: Multiline: Size: Text: |
txtdescription True 400,
84 | |
- Add
the Label
control
- ldescription,
Label Properties
Name: Font: Size: Text: TextAlign: |
ldescription Microsoft Sans
Serif,
8.25pt 80, 16 description
TopLeft | | | | |
|
agenda_task.cs file, the codes after modification
...
|
|
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
work_VCnet10
{
public
partial
class
agenda_task
:
Form
{
public agenda_task()
{
InitializeComponent();
}
// public variables
public
class
agenda_task_cl
{
public
static
bool
task_flag;
}
private
void
agenda_task_Load(object
sender,
EventArgs
e)
{
//new task & edit task
switch
(work_VCnet10.agenda.agenda_cl.task_type)
{
case
"new":
this.Text =
"new task";
this.txtdescription.Text
= "";
this.rad_ligh.Checked
=
false;
this.Rad_normal.Checked
=
true;
this.Rad_low.Checked
=
false;
work_VCnet10. agenda.agenda_cl.task_prirority
=
"N";
break;
case
"edit":
this.Text =
"edit task";
this.txtdescription.Text
= work_VCnet10.agenda.agenda_cl.agenda_desc;
;
switch
(work_VCnet10.agenda.agenda_cl.task_prirority)
{
case
"H":
this.rad_ligh.Checked
=
true;
this.Rad_normal.Checked
=
false;
this.Rad_low.Checked
=
false;
break;
case
"N":
this.rad_ligh.Checked
=
false;
this.Rad_normal.Checked
=
true;
this.Rad_low.Checked
=
false;
break;
case
"L":
this.rad_ligh.Checked
=
false;
this.Rad_normal.Checked
=
false;
this.Rad_low.Checked
=
true;
break;
}
break;
}
agenda_task_cl.task_flag
=
false;
this.Btn_cancel.Left
= (this.txtdescription.Left
+
this.txtdescription.Width)
-
this.Btn_cancel.Width;
this.Btn_ok.Enabled
=
false;
this.txtdescription.Focus();
}
private
void
rad_ligh_CheckedChanged(object
sender,
EventArgs
e)
{
if (this.rad_ligh.Checked
==
true)
{
this.Rad_normal.Checked
=
false;
this.Rad_low.Checked
=
false;
work_VCnet10. agenda.agenda_cl.task_prirority
=
"H";
if (this.Btn_ok.Enabled
==
false)
this.Btn_ok.Enabled
=
true;
this.txtdescription.Focus();
}
}
private
void
Rad_normal_CheckedChanged(object
sender,
EventArgs
e)
{
if (this.Rad_normal.Checked
==
true)
{
this.rad_ligh.Checked
=
false;
this.Rad_low.Checked
=
false;
work_VCnet10. agenda.agenda_cl.task_prirority
=
"N";
if (this.Btn_ok.Enabled
==
false)
this.Btn_ok.Enabled
=
true;
this.txtdescription.Focus();
}
}
private
void
Rad_low_CheckedChanged(object
sender,
EventArgs
e)
{
if (this.Rad_low.Checked
==
true)
{
this.rad_ligh.Checked
=
false;
this.Rad_normal.Checked
=
false;
work_VCnet10. agenda.agenda_cl.task_prirority
=
"L";
if (this.Btn_ok.Enabled
==
false)
this.Btn_ok.Enabled
=
true;
this.txtdescription.Focus();
}
}
private
void
txtdescription_KeyPress(object
sender, System.Windows.Forms.KeyPressEventArgs
e)
{
if (this.Btn_ok.Enabled
==
false)
this.Btn_ok.Enabled
=
true;
}
private
void
Btn_ok_Click(object
sender,
EventArgs
e)
{
if (this.txtdescription.Text.Trim().Length
> 0)
{
switch
(work_VCnet10.agenda.agenda_cl.task_type)
{
case
"new":
agenda_task_cl.task_flag
=
true;
work_VCnet10. agenda.agenda_cl.agenda_desc
=
this.txtdescription.Text;
this.Close();
//work_VCnet10.book_note.ActiveForm.Refresh();
//work_VCnet10.book_note.ActiveForm.Activate();
break;
case
"edit":
agenda_task_cl.task_flag
=
true;
work_VCnet10. agenda.agenda_cl.agenda_desc
=
this.txtdescription.Text;
this.Close();
//work_VCnet10.book_note.ActiveForm.Refresh();
//work_VCnet10.book_note.ActiveForm.Activate();
break;
}
}
else
MessageBox.Show("description
value, empty ... not available",
work_VCnet10.mainform.mainform_cl.Title,
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
private
void
Btn_cancel_Click(object
sender,
EventArgs
e)
{
work_VCnet10. agenda.agenda_cl.agenda_desc
= "";
work_VCnet10. agenda.agenda_cl.task_prirority
= "";
this.Close();
//work_VCnet10.book_note.ActiveForm.Refresh();
//work_VCnet10.book_note.ActiveForm.Activate();
}
}
}
| | |
|
|