Download as pdf or txt
Download as pdf or txt
You are on page 1of 173

C#.

Net
:

" .

"
70 : 71


... ... ...

:
Khalid_Essaadani@Hotmail.Fr

10

13

15 Design environment

29 Controls

29 Properties

34

Events Controls
1 2. 3. 4.

39 39

Button

43 TextBox 46 RichTextBox

47 Label,LinkLabel

48 50

CheckBox

5. 6. 7. 8 9. 10. 11. 12. 13. 14. 15. 16. 17. 18.

RadioButton 52 55 58 ListBox

ComboBox TreeView

62

ImageList 69 ListView

93

DataGridView MenuStrip

104 110

ContextMenuStrip 114 120 ToolStrip StatusStrip 122 124 TabControl GroupBox

124 125 126 130 133

Panel PictureBox

19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32.

ScrollBar TrackBar ProgressBar 134 Timer

137 138

DateTimePicker

MaskedTextBox 140 NotifyIcon

145 146

NumericUpDown DomainUpDown 148 151 153 WebBrowser ColorDialog FontDialog

154

OpenFileDialog 158 SaveFileDialog

33. 34. 35. 36. 37. 173

161

FolderBrowserDialog 162 Print Tools MDI

168

SDI

10

11

12

13

using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.BackgroundColor = ConsoleColor.Yellow; Console.ForegroundColor = ConsoleColor.Red; Console.Write("Hi Brothers ! "); Console.ReadKey(); } } }

Hi Brothers !

14

Console.Beep();

Design environment

New project

File Ctrl+Shift+N

15

Windows Forms

Visual c# Application OK

ToolBox View

16

Ctrl+Alt+X

Form

17

Solution Explorer

Solutions Explorer

View Ctrl+Alt+L

18

Properties

F4

Properties

Error List Compilation

19

Toolbox Button

Text

20

21

BackColor

22

using using using using using using using using

System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

Namespaces

23

using System Collections using IO convert console

System.Console.WriteLine() Console.WriteLine()

using System; using System.Windows.Forms;

System.Windows.Forms System.Windows.Forms.Control
Controls

24

namespace WindowsFormsApplication2

Classes using

public partial class Form1 : Form

Inheritance partial classes Form Form1

partial

Form1.Designer.cs

25

Form1

Form1.Designer.cs

namespace WindowsFormsApplication2 { partial class Form1 { /// <summary> /// Variable ncessaire au concepteur. /// </summary> Form1 namespace WindowsFormsApplication2 { public partial class Form1 : Form

26

public Form1() { InitializeComponent(); }

Form1

Constructor Initialize Form1.Designer.cs IntializeComponent()

Constructors

private void button1_Click(object sender, EventArgs e) { }

Click

27

:
private void button1_Click(object sender, EventArgs e) { MessageBox.Show(";)"! }

28

Controls Textbox Form ListBox Toolbox Button

Properties Control

29

Text

BackColor

Form

BackgroundImage

BackgroundImageLayout

None Tile Stretch Zoom

ForeColor

Font

Name

30

Name

Text

Tab

TabIndex

Width

Height

False

True

Visible

False Enabled True Dock

False

Anchor

31

Parent

Cursor

FormBorderStyle FixedSingle FixedDialog

ico

Icon

1 1 0

Opacity

MaximizeBox

32

MinimizeBox

WindowState

Normal

Maximized

Minimized Location

StartPosition

CenterParent

CenterScreen

33

Manual Location WindowsDefaultBounds

WindowsDefaultLocation

Events

34

Button

35

Click

DoubleClick

BackColorChanged

FormClosing

36

FormClosed

Load

KeyDown

KeyUp

KeyPress KeyPress

KeyUp

KeyDown KeyUp

KeyPress

KeyDown GotFocus

Focus

LostFocus

37

Focus MouseDown

Click

MouseUp

Click MouseMove

Resize

Focus

Validated

38

Validating Focus Validated

Controls

Button Button

39

Click Button Test

Comic Sans MS

40

Click
.

private void button1_Click(object sender, EventArgs e) { this.BackColor=System.Drawing.Color.Green; }

System.Drawing
using System; using System.Windows.Forms; using System.Drawing; namespace ButtonTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.BackColor=Color.Green; } } }

41

Click
private void button2_Click(object sender, EventArgs e) { this.Font = new Font("Comic Sans MS", 12); }

Font

Click

private void button4_Click(object sender, EventArgs e) { this.Close(); }

42

this

TextBox Button Text

TextAlign

MaxLength

43

MultiLine

ReadOnly

PasswordChar

Upper Normal Lower

CharacterCasing

RighToLeft

44

Name

textName

textBox1 Click

private void button1_Click(object sender, EventArgs e) { MessageBox.Show("Salamo alaikom Mr: " + textName.Text); }

45

RichTextBox TextBox

TextBox Microsoft Word

this.richTextBox1.SelectionColor = Color.Red;

this.richTextBox1.SelectionFont = new Font("Times New Roman", 16);

46

Label,LinkLabel

LinkLabel

Label HyperLink

LinkClicked

LinkLabel

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { System.Diagnostics.Process.Start("www.google.com"); }

System.Diagnostics

47

using System; using System.Windows.Forms; using System.Diagnostics; namespace LinkLabelTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { Process.Start("www.google.com"); } } }

CheckBox

48

True

ThreeState

Checked

UnChecked

Click CheckVB Name CheckCS

49

private void button1_Click(object sender, EventArgs e) { // if (CheckVB.Checked == true && CheckCS.Checked == false) { MessageBox.Show("Your Favourite language is : Visual Basic.net"); } // else if (CheckVB.Checked == false && CheckCS.Checked == true) { MessageBox.Show("Your Favourite language is : CSharp.net"); } // else if (CheckVB.Checked == false && CheckCS.Checked == false) { MessageBox.Show("Please Choose Your language !"); } // else { MessageBox.Show("Your Favourite language is : Visual Basic.net and CSharp.Net"); } }

RadioButton

50

CheckBox

RBmarried RBsingle Click


private void button1_Click(object sender, EventArgs e) { if (RBsingle.Checked == true) { MessageBox.Show("You are Single "); } else { MessageBox.Show("You are Married "); } }

51

ListBox :

Items Load

Double Click

52

private void Form1_Load(object sender, EventArgs e) { this.listBox1.Items.Add("First Item"); this.listBox1.Items.Add("Second Item"); this.listBox1.Items.Add("Third Item"); }

initialize()

Form1

public partial class Form1 : Form { public Form1() { InitializeComponent(); this.listBox1.Items.Add("First Item"); this.listBox1.Items.Add("Second Item"); this.listBox1.Items.Add("Third Item"); } }

ListBox

Button

TextBox Label

53

Add To list

Add To list

Click

private void button1_Click(object sender, EventArgs e) { this.listBox1.Items.Add(textBox1.Text); }

Add

private void button2_Click(object sender, EventArgs e) { this.listBox1.Items.RemoveAt(listBox1.SelectedIndex); }

54

RemoveAt SelectedIndex Clear listBox1.SelectedIndex

this.listBox1.Items.Clear();

Arrays

namespace ListBoxFromArrays { public partial class Form1 : Form { public Form1() { InitializeComponent(); string[] WeekDay = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; this.listBox1.Items.AddRange(WeekDay); } } }

ListBox ComboBox

AddRang

55

ListBox

Items AddRange

56

namespace ComboboxTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); string[] Countries = {"Egypt","Morrocco","Algeria","Iraq","Tunisia","Libya"}; this.comboBox1.Items.AddRange(Countries); } } }

SelectedIndexChanged

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { MessageBox.Show("Your Country is : " + comboBox1.Text); }

DropDownList

57

Simple DropDownList DropDown TreeView

Files

Drives

58

Folders

Nodes

59

Node

Nodes

60

namespace TreeViewTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); // treeView1.Nodes.Add("Animal"); treeView1.Nodes[0].Nodes.Add("Tiger"); treeView1.Nodes[0].Nodes.Add("Lion"); treeView1.Nodes[0].Nodes.Add("Cat"); treeView1.Nodes[0].Nodes.Add("Dog"); treeView1.Nodes[0].Nodes.Add("Cow"); // treeView1.Nodes.Add("Language"); treeView1.Nodes[1].Nodes.Add("Visual Basic.net"); treeView1.Nodes[1].Nodes.Add("Csharp.net"); treeView1.Nodes[1].Nodes.Add("J2EE"); treeView1.Nodes[1].Nodes.Add("Python"); treeView1.Nodes[1].Nodes.Add("C++"); treeView1.Nodes[1].Nodes.Add("Delphi"); } } }

ImageList

61

ImageList

10

Images TreeView

62

ImageList

63

OK ImageList Treeview ImageList1 TreeView ImageList

64

ImageList1 1 0 TreeView
treeView1.Nodes.Add("Animal");

ImageList1

Add

65

treeView1.Nodes.Add("" ,"" , , ;)

public partial class Form1 : Form { public Form1() { InitializeComponent(); // treeView1.Nodes.Add("","Animal",0,0); treeView1.Nodes[0].Nodes.Add("", "Tiger", 1, 1); treeView1.Nodes[0].Nodes.Add("", "Lion", 1, 1); treeView1.Nodes[0].Nodes.Add("", "Cat", 1, 1); treeView1.Nodes[0].Nodes.Add("", "Dog", 1, 1); treeView1.Nodes[0].Nodes.Add("", "Cow", 1, 1); // treeView1.Nodes.Add("", "Language", 0,0); treeView1.Nodes[1].Nodes.Add("", "Visual Basic.net", 1, 1); treeView1.Nodes[1].Nodes.Add("", "Csharp.net", 1, 1); treeView1.Nodes[1].Nodes.Add("", "J2EE", 1, 1); treeView1.Nodes[1].Nodes.Add("", "Python", 1, 1); treeView1.Nodes[1].Nodes.Add("", "C++", 1, 1); treeView1.Nodes[1].Nodes.Add("", "Delphi", 1, 1); } }

F5

66

!!! False CheckBoxes TreeView True

67

Checked
foreach (TreeNode Node in this.treeView1.Nodes) { if (Node.Checked == true) { //Do Something :) } }

68

ListView ListBox

11

Windows Explorer

69

. ListView

DropDownList

DropDownStyle

ImageList

ListView

ImageList1 ListView

70

71

ListView

Edit Items Edit Columns

Edit Groups

Tile

List Small ImageList

View

Large ImageList

72

ImageList1 Listview
namespace TreeViewTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); listView1.Items.Add("Folder listView1.Items.Add("Folder listView1.Items.Add("Folder listView1.Items.Add("Folder listView1.Items.Add("Folder } } }

1", 2", 3", 4", 5",

0); 0); 0); 0); 0);

Add

73

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox1.Text == "LargeIcon") { listView1.View = View.LargeIcon; } else if (comboBox1.Text == "Details") { listView1.View = View.Details; } else if (comboBox1.Text == "SmallIcon") { listView1.View = View.SmallIcon; } else if (comboBox1.Text == "List") { listView1.View = View.List; } else { listView1.View = View.Tile; } }

ListView Column Header

Details

74

Edit Columns

public partial class Form1 : Form { public Form1() { InitializeComponent(); listView1.Columns.Add("Name"); listView1.Columns.Add("Description"); listView1.Items.Add("Folder 1", 0); listView1.Items.Add("Folder 2", 0); listView1.Items.Add("Folder 3", 0); listView1.Items.Add("Folder 4", 0); listView1.Items.Add("Folder 5", 0); } }

75

Methodes

76

ListView TreeView ListView

ImageList

77

ImageList

ListView1

ImageList1 lvDrives Name

78

tvFolders

lvFiles

FileName Length Last Access

Type

79

80

ImageList1

81

System.IO

using System; using System.Windows.Forms;

using System.IO;

strDrive

using System; using System.Windows.Forms; using System.IO; namespace WindowsFormsApplication1 { public partial class Form1 : Form { string strDrive;

Methods

82

:getDrives()

lvDrives
:getFolders() :getFiles(string strPath)

getDrives()

void getDrives() { foreach (string drive in Directory.GetLogicalDrives()) { this.lvDrives.Items.Add(drive,0); } }

GetLogicalDrives() lvDrives
getFolders() void getFolders() { strDrive = lvDrives.FocusedItem.Text; DirectoryInfo Dir = new DirectoryInfo(strDrive); tvFolders.Nodes.Clear(); foreach (DirectoryInfo Folder in Dir.GetDirectories()) { tvFolders.Nodes.Add("", Folder.Name, 1, 1); } }

Directory

83

strDrive = lvDrives.FocusedItem.Text;

strDrive

DirectoryInfo Dir = new DirectoryInfo(strDrive);

strDrive

Dir DirectoryInfo
tvFolders.Nodes.Clear();

tvFolders Drives
foreach (DirectoryInfo Folder in Dir.GetDirectories()) { tvFolders.Nodes.Add("", Folder.Name, 1, 1); }

tvFolders DirectoryInfo GetDirectories

84

getFiles(string strPath)
void getFiles(string strPath) { ListViewItem lvi; DirectoryInfo Dir = new DirectoryInfo(strDrive+ strPath); lvFiles.Items.Clear(); foreach (FileInfo file in Dir.GetFiles()) { lvi = lvFiles.Items.Add(file.Name,2); lvi.SubItems.Add(file.Length.ToString()); lvi.SubItems.Add(file.LastAccessTime.ToString()); lvi.SubItems.Add(file.Extension); } }

strPath

ListViewItem lvi;

ListViewItem

lvi lvFiles

DirectoryInfo Dir = new DirectoryInfo(strDrive+ strPath);

Drives

85

lvFiles.Items.Clear();

foreach (FileInfo file in Dir.GetFiles()) { lvi = lvFiles.Items.Add(file.Name,2); lvi.SubItems.Add(file.Length.ToString()); lvi.SubItems.Add(file.LastAccessTime.ToString()); lvi.SubItems.Add(file.Extension); }

lvFiles lvi FileInfo GetFiles()

getDrives()

InitializeComponent()
public Form1() { InitializeComponent(); getDrives(); }

86

Double_Click
private void lvDrives_DoubleClick(object sender, EventArgs e) { getFolders(); }

After_Select tvFolders
private void tvFolders_AfterSelect(object sender, TreeViewEventArgs e) { getFiles(e.Node.FullPath); TreeNode node; DirectoryInfo Dir = new DirectoryInfo(strDrive + e.Node.FullPath); foreach (DirectoryInfo folder in Dir.GetDirectories()) { node = new TreeNode(folder.Name, 1, 1); e.Node.Nodes.Add(node); } }

getFiles(e.Node.FullPath);

e.Node.FullPath

87

TreeNode node;

node

DirectoryInfo Dir = new DirectoryInfo(strDrive + e.Node.FullPath);

88

foreach (DirectoryInfo folder in Dir.GetDirectories()) { node = new TreeNode(folder.Name, 1, 1); e.Node.Nodes.Add(node); }

89

using System; using System.Windows.Forms; using System.IO; namespace WindowsExplorer { public partial class Form1 : Form { string strDrive; //First method void getDrives() { foreach (string drive in Directory.GetLogicalDrives()) { this.lvDrives.Items.Add(drive,0); } } //Second Method void getFolders() { strDrive = lvDrives.FocusedItem.Text; DirectoryInfo Dir = new DirectoryInfo(strDrive); tvFolders.Nodes.Clear(); foreach (DirectoryInfo Folder in Dir.GetDirectories()) { tvFolders.Nodes.Add("", Folder.Name, 1, 1); } } //Third Method void getFiles(string strPath) { ListViewItem lvi; DirectoryInfo Dir = new DirectoryInfo(strDrive+ strPath); lvFiles.Items.Clear(); foreach (FileInfo file in Dir.GetFiles()) { lvi = lvFiles.Items.Add(file.Name,2); lvi.SubItems.Add(file.Length.ToString()); lvi.SubItems.Add(file.LastAccessTime.ToString()); lvi.SubItems.Add(file.Extension); } }

90

public Form1() { InitializeComponent(); getDrives(); } private void lvDrives_DoubleClick(object sender, EventArgs e) { getFolders(); } private void tvFolders_AfterSelect(object sender, TreeViewEventArgs e) { getFiles(e.Node.FullPath); // TreeNode node; DirectoryInfo Dir = new DirectoryInfo(strDrive + e.Node.FullPath); foreach (DirectoryInfo folder in Dir.GetDirectories()) { node = new TreeNode(folder.Name, 1, 1); e.Node.Nodes.Add(node); } } } }

ListView Grouping

91

ImageList

ListView

InitializeComponent()
//Create 3 groups listView1.Groups.Add("", "Programmes"); listView1.Groups.Add("", "Books"); listView1.Groups.Add("", "Media"); //Add 2 items to the first group listView1.Items.Add("Internet explorer", 1); listView1.Items[0].Group = listView1.Groups[0]; listView1.Items.Add("Adobe Photoshop", 0); listView1.Items[1].Group = listView1.Groups[0]; //Add 1 item to the second group listView1.Items.Add("" , 3); listView1.Items[2].Group = listView1.Groups[1]; //Add 1 item to the third group listView1.Items.Add("Western Film", 2); listView1.Items[3].Group = listView1.Groups[2];

92

DataGridView

12

Excel

93

. DataGridView

DataGridView

94

Choose Data Source

95

Edit Columns ListView

Add

96

DataGridViewButtonColumn Button DataGridViewCheckBoxColumn CheckBoxe DataGridViewComboBoxColumn ComboBox DataGridViewImageColumn Image

97

DataGridViewLinkColumn Link DataGridViewTextBoxColumn TextBox

Add Columns Enable Adding

Enable Editing

98

Enable Deleting DataGridView Enable Column Reordering

DataGridView DataTable DataTable DataGridView DataGridView

DataTable

99

Columns

Arrays Rows

System.Data

dTable
DataTable dTable = new DataTable();

dTable

DataColumn

DataColumn Name = new DataColumn("Name",typeof(string)); dTable.Columns.Add(Name); DataColumn Address = new DataColumn("Address",typeof(string)); dTable.Columns.Add(Address); DataColumn BirthDate = new DataColumn("Birth Date",typeof(DateTime)); dTable.Columns.Add(BirthDate);

100

DataTable TypeOf()

Column

DataColumn

dTable DataTable Rows dTable

dTable.Rows.Add(new object[] { "Khalid", "Morocco", new DateTime(1989, 5, 18) }); dTable.Rows.Add(new object[] { "Hamid", "France", new DateTime(1989, 10, 22) }); dTable.Rows.Add(new object[] { "Mohamed", "Canada", new DateTime(1988, 9, 1) }); dTable.Rows.Add(new object[] { "Younes", "Italia", new DateTime(187, 7, 12) });

dTable

Rows

dTable object

DataGridView

101

this.dataGridView1.DataSource = dTable;

namespace DataGridViewTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); DataTable dTable = new DataTable(); DataColumn Name = new DataColumn("Name",typeof(String)); dTable.Columns.Add(Name); DataColumn Address = new DataColumn("Address",typeof(String)); dTable.Columns.Add(Address); DataColumn BirthDate = new DataColumn("Birth Date",typeof(DateTime)); dTable.Columns.Add(BirthDate); dTable.Rows.Add(new new DateTime(1989, 5, 18) }); dTable.Rows.Add(new DateTime(1989, 10, 22) }); dTable.Rows.Add(new new DateTime(1988, 9, 1) }); dTable.Rows.Add(new new DateTime(187, 7, 12) }); } } } object[] { "Khalid ESSAADANI", "Morocco", object[] { "Hamid MAKBOUL", "France", new object[] { "Mohamed ELKHAL", "Canada", object[] { "Younes MAADANE", "Italia",

this.dataGridView1.DataSource = dTable;

102

DataGridView

AllowUserToAddRows

False

True AllowUserToDeleteRows

False

True AllowUserToOrderColumns

False

True AllowUserToResizeColumns

False

True AllowUserToResizeRows

False

True AlternatingRowsDefaultCellStyle

AutoSizeColumnsMode DataGridView Fill

103

BackGroundColor Cells DefaultCellStyle MultiSelect DataGridView ReadOnly

ScrollBars

SelectionMode

FullRowSelect

MenuStrip

13

104

MenuStrip

105

MenuItem ComboBox

Forms MenuStrip

106

File

Form1

MenuStrip Show Form2

Windows Form

Add

Ctrl+Shift+A

107

OK

Form2 2

Form2 frm;

Show Form2 Click

108

private void ShowForm2ToolStripMenuItem_Click(object sender, EventArgs e) { frm = new Form2(); frm.Show(); }

Show() Show Form2

Form2

109

ContextMenuStrip

14

ContextMenuStrip .

110

MenuStrip

ContextMenuStrip1

ContextMenu

111

112

ContextMenuStrip

:DataGridView

113

ToolStrip

15

ToolStrip

114

Button

TextBox

2 Buttons

ToolStrip

115

Label ToolStrip1 TextChanged Label1

private void toolStripTextBox1_TextChanged(object sender, EventArgs e) { this.label1.Text = toolStripTextBox1.Text; }

TextChanged Label1

116

toolStripTextBox1 ToolStrip

Label1

size
public partial class Form1 : Form { int size = 12; public Form1() { InitializeComponent(); }

117

Click

private void toolStripButton1_Click(object sender, EventArgs e) { this.label1.Font =new Font("Tahoma", size); size += 4; }

4 4 -

private void toolStripButton2_Click(object sender, EventArgs e) { this.label1.Font = new Font("Tahoma", size); size -= 4; }

size

118

private void toolStripButton2_Click(object sender, EventArgs e) { if (size == 0) { size = 8; } this.label1.Font = new Font("", size); size -= 4; }

ToolStrip

119

StatusStrip

16

Microsoft Word

StatusLabel

120

InitializeComponent()
public partial class Form1 : Form { public Form1() { InitializeComponent(); this.toolStripStatusLabel1.Text = "Today is: " + DateTime.Now; this.toolStripStatusLabel1.Text += " The computer name is: " + Environment.MachineName; } }

DateTime MachineName

Now

Environnement

121

TabControl

17

Views

122

TabControl

Tabs

TabPages

SelectTab

123

tabControl1.SelectTab(1);

GroupBox Radio

18

Button

Panel GroupBox Fixed3D FixedSingle BorderStyle

19

124

Visible Vertical GroupBox Horizontal Scrollbars FixedSingle BorderStyle True AutoScroll ScrollBars

PictureBox

20

BackGroundImage

Image

125

BackGroundImageLayout

None Tile Center Stretch Zoom FromFile PictureBox Image


this.pictureBox1.Image = Image.FromFile("MyPic.JPG");

ScrollBar VScrollBar

21

HScrollBar

126

HScrollBar

VScrollBar

Panel

VScrollBar

HScrollBar

TrackBar . Adobe Photoshop HScrollBar

127

TrackBar HScrollBar

128

250

Maximum

Minimum .

Scroll

private void RedSB_Scroll(object sender, ScrollEventArgs e) { this.BackColor = Color.FromArgb(RedSB.Value, GreenSB.Value, BlueSB.Value); } FromArgb

this.BackColor = Color.FromArgb(1, 1, 1);

this.BackColor = Color.FromArgb(RedSB.Value, GreenSB.Value, BlueSB.Value);

Scroll

129

TrackBar

22

130

PictureBox

TrackBar

pictureBox1 trackBar1 Maximum Minimum pictureBox1 trackBar1 Size Scroll Minimum

131

private void trackBar1_Scroll(object sender, EventArgs e) { this.pictureBox1.Size = new Size(trackBar1.Value, trackBar1.Value); }

trackBar1

132

ProgressBar

23

Maximum value Increment Timer

Minimum

Style Blocks Marquee

133

Continuous

Timer Run Time

24

False True

Enabled

True Interval

MilliSecond 1 second=1000 MilliSecond

134

1000

Interval timer1

True

Enabled Label Tick

private void timer1_Tick(object sender, EventArgs e) { this.label1.Text = DateTime.Now.ToLongTimeString(); }

ToLongTimeString

1000

Interval

135

ProgressBar Timer Interval

Enabled

Timer

ProgressBar Interval

timer1

Tick

private void timer1_Tick(object sender, EventArgs e) { while (progressBar1.Value < progressBar1.Maximum) { progressBar1.Value += 2; } }

136

progressBar1 progressBar1 timer1 Interval Loading Enabled DateTimePicker

25

137

value
DateTime mydate = this.dateTimePicker1.Value;

MaskedTextBox TextBox

26

Mask

138


Blank

0 9 #

L ? & C A . , :
139

/ $ <
Lower Case

>
Upper case

|
NotifyIcon

27

InitializeComponent

140

notifyIcon1.Icon = this.Icon; notifyIcon1.BalloonTipIcon = ToolTipIcon.Warning; notifyIcon1.BalloonTipText = "Please update your program to the last version !"; notifyIcon1.BalloonTipTitle = "Warning Update"; notifyIcon1.ShowBalloonTip(12);

notifyIcon1

Icon

BalloonTipIcon

None

Error

Warning

141

Info

BalloonTipIcon

notifyIcon1.BalloonTipText = "Please update your program to the last version !";

notifyIcon1.BalloonTipTitle = "Warning Update";

notifyIcon1.ShowBalloonTip(12);

12 s

notifyIcon1.Icon = this.Icon; notifyIcon1.ShowBalloonTip(12, "Warning Update", "Update Your..", ToolTipIcon.Error);

142

ContextMenuStrip

NotifyIcon

ContextMenuStrip NotifyIcon ContextMenuStrip ContextMenuStrip

143

ContextMenuStrip1

ContextMenuStrip

notifyIcon1

public Form1() { InitializeComponent(); notifyIcon1.Icon = this.Icon; notifyIcon1.Visible = true; }

144

NumericUpDown

28

Maximum decimal Value

Minimum

decimal number = numericUpDown1.Value;

145

DecimalPlaces 2

Integer 0,01 Increment

numericUpDown1 ValueChanged DomainUpDown

29

146

Items

this.domainUpDown1.Items.Add("my First item");

147

SelectedIndex

this.domainUpDown1.SelectedIndex = 5;

SelectedItemChanged WebBrowser Google Chrome Internet Explorer

30

WebBrowser

148

149

Label Button Button TextBox

MaskedTextBox

Button WebBrowser Anchor

150

Click

Go

webBrowser1.Navigate(textBox1.Text);

Navigate Click
webBrowser1.GoBack();

webBrowser1.GoForward();

GoHome Refresh

ColorDialog

31

Color
this.BackColor = colorDialog1.Color;

ColorDialog

151

Button

ColorDialog

152

Click

ColorDialog Button

private void button1_Click(object sender, EventArgs e) { colorDialog1.ShowDialog(); this.BackColor = colorDialog1.Color; }

ShowDialog

FontDialog Font

32

153

Click

private void button1_Click(object sender, EventArgs e) { fontDialog1.ShowDialog(); this.Font = fontDialog1.Font; }

Font

OpenFileDialog openFileDialog

33

154

Click
openFileDialog1.ShowDialog();

155

FileName

Filter

*.GIF

*.JPG *.TXT

Images Files|*.JPEG;*.PNG InitialDirectory SaveFileDialog Title PictureBox OpenFileDialog

156

Click
openFileDialog1.Filter = "Images Files|*.JPG;*.GIF,*.PNG"; openFileDialog1.Title = "Open your image"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { pictureBox1.Image = Image.FromFile(openFileDialog1.FileName); }

157

OK pictureBox1

SaveFileDialog

34

158

FileName

OK ShowDialog DialogResult.OK Filter

159

*.GIF

*.JPG *.TXT

Images Files|*.JPEG;*.PNG InitialDirectory SaveFileDialog Title

Save Text

Click

160

saveFileDialog1.Title = "Save Your Text"; saveFileDialog1.Filter = "Text Documents | *.TXT"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { System.IO.File.WriteAllText(saveFileDialog1.FileName, richTextBox1.Text); }

richTextBox1 FolderBrowserDialog Folders

35

161

SelectedPath
string folderPath = folderBrowserDialog1.SelectedPath;

Print Tools

36

PrintDocument Crystal Report Databases PrintDocument


:PageSetupDialog

c#

162

PrintPreviewDialog

PrintDialog

163

PrintDocument

RichTextBox

164

printDocument1

Document printDocument1

165

PrintPage

PrintDocument

PrintDocument

e.Graphics.DrawString(richTextBox1.Text, new Font("Tahoma", 18), Brushes.Blue,10,20);

Graphics

DrawString

RichTextBox 18 Tahoma

166

PrintDocument Page Setup


pageSetupDialog1.ShowDialog();

Click

Preview
printPreviewDialog1.ShowDialog();

Click

Click
printDialog1.ShowDialog();

DrawString Graphics

167

DrawImage

Graphics

e.Graphics.DrawImage(Image.FromFile("c:\\c.png"), new Point(10, 10));

SDI

MDI

37

Dialog-Based Application (DBA)

168

Single-Document Interfaces (SDI) Notepad Menu

Multiple-Document Interfaces (MDI)

MenuStrip

169

IsMdiContainer True MDI Parent MDI Container

Click

Open a child form

Form frmChild = new Form(); frmChild.MdiParent = this; frmChild.Show();

frmChild this

170

True

IsMdiContainer

MdiParent

171

Form2 frmChild = new Form2(); frmChild.MdiParent = this; frmChild.Show();

172

Khalid_ESSAADANI@Hotmail.Fr

173

You might also like