برمجة الواجهات (خالد السعدني).pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

‫سبيلك املختصر‬ ‫لتعلم لغة‬ ‫‪C#.Net‬‬ ‫من إعداد ‪ :‬خالد السعداني‬ ‫‪2‬‬ ‫"يا أيها الرين آمنىا اتقىا اهلل و قىلىا قىال سديدا‪.‬‬ ‫يصلح لكم أعمالكم و يغفس لكم ذنىبكم‬ ‫ومن يطع اهلل و زسىله فقد فاش فىشا عظيما"‬ ‫األحزاب ‪ 70 :‬و ‪71‬‬ ‫‪3‬‬ ‫...

‫سبيلك املختصر‬ ‫لتعلم لغة‬ ‫‪C#.Net‬‬ ‫من إعداد ‪ :‬خالد السعداني‬ ‫‪2‬‬ ‫"يا أيها الرين آمنىا اتقىا اهلل و قىلىا قىال سديدا‪.‬‬ ‫يصلح لكم أعمالكم و يغفس لكم ذنىبكم‬ ‫ومن يطع اهلل و زسىله فقد فاش فىشا عظيما"‬ ‫األحزاب ‪ 70 :‬و ‪71‬‬ ‫‪3‬‬ ‫إهداء‬ ‫إىل الوالدين أوال وأخريا‪...‬‬ ‫إىل أحبائي متتبعي السلسلة‪...‬‬ ‫إىل كل املسلمني واملسلمات‪...‬‬ ‫اللهم اجعله عمال خالصا‬ ‫لوجهك‬ ‫‪4‬‬ ‫عند وجود أي مالحظة‪،‬‬ ‫املرجو مراسليت عرب ‪:‬‬ ‫‪[email protected]‬‬ ‫‪5‬‬ 6 10 13 15 Design environment 29 Controls 29 Properties 34 Events 39 Controls 39 Button 1 43 TextBox 2. 46 RichTextBox 3. 47 Label,LinkLabel 4. 6 48 CheckBox 5. 50 RadioButton 6. 52 ListBox 7. 55 ComboBox 8 58 TreeView 9. 62 ImageList 10. 69 ListView 11. 93 DataGridView 12. 104 MenuStrip 13. 110 ContextMenuStrip 14. 114 ToolStrip 15. 120 StatusStrip 16. 122 TabControl 17. 124 GroupBox 18. 7 124 Panel 19. 125 PictureBox 20. 126 ScrollBar 21. 130 TrackBar 22. 133 ProgressBar 23. 134 Timer 24. 137 DateTimePicker 25. 138 MaskedTextBox 26. 140 NotifyIcon 27. 145 NumericUpDown 28. 146 DomainUpDown 29. 148 WebBrowser 30. 151 ColorDialog 31. 153 FontDialog 32. 8 154 OpenFileDialog 33. 158 SaveFileDialog 34. 161 FolderBrowserDialog 35. 162 Print Tools 36. 168 SDI MDI 37. 173 9 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 1 View 16 Ctrl+Alt+X Form 2 4 17 Solution Explorer 3 Solutions Explorer View Ctrl+Alt+L 18 Properties 4 F4 Properties Error List 5 Compilation 19 Toolbox Button Text 20 21 BackColor : 22 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; Namespaces 23 using System Collections IO convert console using System.Console.WriteLine() Console.WriteLine() 1 using System; using System.Windows.Forms; 2 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 { /// /// Variable nécessaire au concepteur. /// Form1 namespace WindowsFormsApplication2 { public partial class Form1 : Form 26 public Form1() { InitializeComponent(); } Form1 Constructor Initialize IntializeComponent() Form1.Designer.cs 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 Button Toolbox - - Properties Control 29 Text BackColor BackgroundImage Form BackgroundImageLayout None Tile Stretch Zoom ForeColor Font Name 30 Name Text TabIndex Tab Width Height Visible False True False Enabled False True Dock Anchor 31 Parent Cursor FormBorderStyle FixedSingle FixedDialog Icon ico Opacity 1 0 1 0 MaximizeBox 32 MinimizeBox WindowState Normal Maximized Minimized Location Y X 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 Validated Focus 38 Validating Focus Validated Controls Button Button 1 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 2 Button Text. ‫صورة ألداة علبة النص‬ ‫دورها‬ ‫الخصيصة‬ TextAlign MaxLength 43 MultiLine ReadOnly PasswordChar CharacterCasing Upper Normal Lower RighToLeft 44 Name textName textBox1 Click private void button1_Click(object sender, EventArgs e) { MessageBox.Show("Salamo alaikom Mr: " + textName.Text); } 45 RichTextBox 3 TextBox TextBox Microsoft Word this.richTextBox1.SelectionColor = Color.Red; this.richTextBox1.SelectionFont = new Font("Times New Roman", 16); 46 Label,LinkLabel 4 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 5 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 6 : 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 7 : 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 listBox1.SelectedIndex Clear 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 AddRang ComboBox 8 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 9 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.Nodes.Add("Tiger"); treeView1.Nodes.Nodes.Add("Lion"); treeView1.Nodes.Nodes.Add("Cat"); treeView1.Nodes.Nodes.Add("Dog"); treeView1.Nodes.Nodes.Add("Cow"); //‫إضبفخ العقذح الثبنٍخ وتفشٌعبتهب‬ treeView1.Nodes.Add("Language"); treeView1.Nodes.Nodes.Add("Visual Basic.net"); treeView1.Nodes.Nodes.Add("Csharp.net"); treeView1.Nodes.Nodes.Add("J2EE"); treeView1.Nodes.Nodes.Add("Python"); treeView1.Nodes.Nodes.Add("C++"); treeView1.Nodes.Nodes.Add("Delphi"); } } } ImageList 61 ImageList 10 Images TreeView 62 ImageList 63 OK ImageList Treeview TreeView ImageList1 ImageList 64 ImageList1 1 0 ImageList1 TreeView treeView1.Nodes.Add("Animal"); Add 65 treeView1.Nodes.Add("‫" اسن العقذح‬,"‫" قٍوخ العقذح‬,‫ تشتٍت الصىسح‬, ‫تشتٍت‬ ‫;) الصىسح عنذ التحذٌذ‬ 1 0 public partial class Form1 : Form { public Form1() { InitializeComponent(); //‫وتفشٌعبتهب األولى العقذح إضبفخ‬ treeView1.Nodes.Add("","Animal",0,0); treeView1.Nodes.Nodes.Add("", "Tiger", 1, 1); treeView1.Nodes.Nodes.Add("", "Lion", 1, 1); treeView1.Nodes.Nodes.Add("", "Cat", 1, 1); treeView1.Nodes.Nodes.Add("", "Dog", 1, 1); treeView1.Nodes.Nodes.Add("", "Cow", 1, 1); //‫وتفشٌعبتهب الثبنٍخ العقذح إضبفخ‬ treeView1.Nodes.Add("", "Language", 0,0); treeView1.Nodes.Nodes.Add("", "Visual Basic.net", 1, 1); treeView1.Nodes.Nodes.Add("", "Csharp.net", 1, 1); treeView1.Nodes.Nodes.Add("", "J2EE", 1, 1); treeView1.Nodes.Nodes.Add("", "Python", 1, 1); treeView1.Nodes.Nodes.Add("", "C++", 1, 1); treeView1.Nodes.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 11 ListBox Windows Explorer 69. DropDownList DropDownStyle ListView ImageList ListView ImageList1 ListView 70 ‫نضغط على هذا السهم لتظهر لنا النافذة التالية‪:‬‬ ‫‪71‬‬ ListView Edit Items Edit Columns Edit Groups Tile List View Small ImageList Large ImageList 72 ImageList1 Listview namespace TreeViewTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); 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); } } } 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 Details Column Header 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 Directory 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); } } 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.Group = listView1.Groups; listView1.Items.Add("Adobe Photoshop", 0); listView1.Items.Group = listView1.Groups; //Add 1 item to the second group listView1.Items.Add("‫"تبسٌخ الوغشة‬, 3); listView1.Items.Group = listView1.Groups; //Add 1 item to the third group listView1.Items.Add("Western Film", 2); listView1.Items.Group = listView1.Groups; 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 DataGridView DataTable 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 Column DataColumn TypeOf() 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 object[] { "Khalid ESSAADANI", "Morocco", new DateTime(1989, 5, 18) }); dTable.Rows.Add(new object[] { "Hamid MAKBOUL", "France", new DateTime(1989, 10, 22) }); dTable.Rows.Add(new object[] { "Mohamed ELKHAL", "Canada", new DateTime(1988, 9, 1) }); dTable.Rows.Add(new object[] { "Younes MAADANE", "Italia", new DateTime(187, 7, 12) }); 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 DefaultCellStyle Cells MultiSelect ReadOnly DataGridView 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() Form2 Show 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 - Label1 TextChanged 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 8 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; } 0 size 0 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 Now MachineName Environnement 121 TabControl 17 Views 122 TabControl Tabs TabPages SelectTab 123 tabControl1.SelectTab(1); 0 GroupBox 18 Radio Button Panel 19 GroupBox Fixed3D FixedSingle BorderStyle 124 Visible Vertical GroupBox Horizontal Scrollbars ScrollBars FixedSingle BorderStyle True AutoScroll PictureBox 20 BackGroundImage Image 125 BackGroundImageLayout None Tile Center Stretch Zoom FromFile PictureBox Image this.pictureBox1.Image = Image.FromFile("MyPic.JPG"); ScrollBar 21 VScrollBar HScrollBar 126 HScrollBar VScrollBar Panel VScrollBar HScrollBar TrackBar. HScrollBar Adobe Photoshop 127 TrackBar HScrollBar 128 250 Maximum 0 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 Size Minimum trackBar1 Scroll 131 private void trackBar1_Scroll(object sender, EventArgs e) { this.pictureBox1.Size = new Size(trackBar1.Value, trackBar1.Value); } trackBar1 132 ProgressBar 23 Maximum Minimum value Increment Timer Style Blocks Marquee 133 Continuous Timer 24 Run Time ‫دورها‬ ‫الخصيصة‬ Enabled False True True Interval MilliSecond 1 second=1000 MilliSecond 134 1000 Interval True Enabled timer1 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 26 TextBox Mask 138 ‫دوره‬ ‫الرمز‬ ‫‪0‬‬ ‫‪Blank‬‬ ‫‪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 Minimum decimal Value 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 30 Google Chrome Internet Explorer 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 32 Font 153 Click private void button1_Click(object sender, EventArgs e) { fontDialog1.ShowDialog(); this.Font = fontDialog1.Font; } Font OpenFileDialog 33 openFileDialog 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 35 Folders 161 SelectedPath string folderPath = folderBrowserDialog1.SelectedPath; Print Tools 36 PrintDocument c# Crystal Report Databases PrintDocument :PageSetupDialog 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 Click pageSetupDialog1.ShowDialog(); Preview Click printPreviewDialog1.ShowDialog(); 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 2 1 True IsMdiContainer   MdiParent 171 Form2 frmChild = new Form2(); frmChild.MdiParent = this; frmChild.Show(); 172 [email protected] 173

Use Quizgecko on...
Browser
Browser