|
The Form design,
agenda_task.cs
Create Visual C# .Net Forn - agenda_task.cs
Classes used in this
Form:
PictureBox,
RadioButton, Button, ImageList, TextBox, Label,
GroupBox
- On the View menu ,
click Solution Explorer
- In Solution
Explorer
In Solution Explorer, right click the
work_VCnet, select Add on the shortcut menu to
open other shortcut menu, click Add New Item,
the Add New Item - work_VCnet dialog box
appears. |

|
- In the Add New
Item -work_VCnet dialog box:
- In the
Categories pane, select Local Project
Items
- In the Templates
pane, select Windows form . A message
appears - (a form for Windows Applications).
- In the Name
box, type agenda_task.cs
- Click
Open
|

|
- In the windows
Forms Designer appears the empty window Form
design
|
1. |
Picture files used by this form ...
|
|
- The folder
c:\work_VCnet\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_VCnet\pic\p_high.bmp
- PicA2 -
Bitmap file added = C:\work_VCnet\pic\p_low.bmp
- Pic\A3 -
Bitmap file added = C:\work_VCnet\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_VCnet\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
...
The
text
Code
is red color, the codes added manuel |
|
using
System;
using
System.Drawing;
using
System.Collections;
using
System.ComponentModel;
using
System.Windows.Forms;
namespace
work_VCnet
{
///
<summary>
///
Summary description for agenda_task.
///
</summary>
public
class
agenda_task : System.Windows.Forms.Form
{
internal
System.Windows.Forms.Label ldescription;
internal
System.Windows.Forms.Button Btn_cancel;
internal
System.Windows.Forms.ImageList ImageList1;
internal
System.Windows.Forms.Button Btn_ok;
internal
System.Windows.Forms.GroupBox GroupBox1;
internal
System.Windows.Forms.PictureBox PicA3;
internal
System.Windows.Forms.PictureBox PicA2;
internal
System.Windows.Forms.PictureBox PicA1;
internal
System.Windows.Forms.RadioButton Rad_low;
internal
System.Windows.Forms.RadioButton Rad_normal;
internal
System.Windows.Forms.RadioButton rad_ligh;
internal
System.Windows.Forms.TextBox txtdescription;
private
System.ComponentModel.IContainer components;
public
agenda_task()
{
//
// Required for
Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any
constructor code after InitializeComponent call
//
}
///
<summary>
///
Clean up any resources being used.
///
</summary>
protected
override
void
Dispose( bool
disposing )
{
if(
disposing )
{
if(components
!= null)
{
components.Dispose();
}
}
base.Dispose(
disposing );
}
Windows Form Designer
generated code |
// public variables
public class
agenda_task_cl
{
public static
bool task_flag;
}
private void
agenda_task_Load(object
sender, System.EventArgs e)
{
//new task & edit
task
switch(work_VCnet.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_VCnet.agenda.agenda_cl.task_prirority = "N";
break;
case
"edit":
this.Text
= "edit task";
this.txtdescription.Text
= work_VCnet.agenda.agenda_cl.agenda_desc;
;
switch(work_VCnet.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, System.EventArgs e)
{
if (this.rad_ligh.Checked
== true)
{
this.Rad_normal.Checked = false;
this.Rad_low.Checked = false;
work_VCnet.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, System.EventArgs e)
{
if (this.Rad_normal.Checked
== true)
{
this.rad_ligh.Checked = false;
this.Rad_low.Checked = false;
work_VCnet.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, System.EventArgs e)
{
if (this.Rad_low.Checked
== true)
{
this.rad_ligh.Checked = false;
this.Rad_normal.Checked = false;
work_VCnet.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, System.EventArgs e)
{
if (this.txtdescription.Text.Trim().Length
> 0)
{
switch(work_VCnet.agenda.agenda_cl.task_type)
{
case
"new":
agenda_task_cl.task_flag =
true;
work_VCnet.agenda.agenda_cl.agenda_desc =
this.txtdescription.Text;
this.Close();
//work_VCnet.book_note.ActiveForm.Refresh();
//work_VCnet.book_note.ActiveForm.Activate();
break;
case
"edit":
agenda_task_cl.task_flag =
true;
work_VCnet.agenda.agenda_cl.agenda_desc =
this.txtdescription.Text;
this.Close();
//work_VCnet.book_note.ActiveForm.Refresh();
//work_VCnet.book_note.ActiveForm.Activate();
break;
}
}
else
MessageBox.Show("description
value, empty ... not available",
work_VCnet.mainform.mainform_cl.Title,
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void
Btn_cancel_Click(object
sender, System.EventArgs e)
{
work_VCnet.agenda.agenda_cl.agenda_desc = "";
work_VCnet.agenda.agenda_cl.task_prirority = "";
this.Close();
//work_VCnet.book_note.ActiveForm.Refresh();
//work_VCnet.book_note.ActiveForm.Activate();
}
}
}
| | |
|
|