מבוא לתכנות בWINDOWS ב#C

Slides:



Advertisements
Similar presentations
מבוא למדעי המחשב לתעשייה וניהול
Advertisements

מבוא לתכנות ב WINDOWS ד " ר אבי רוזנפלד ד " ר אריאלה ריכרדסון.
1 תוכנה 1 תרגול 14 – סיכום. 2 קצת על מנשקים מנשק יכול להרחיב יותר ממנשק אחד שירותים במנשק הם תמיד מופשטים וציבוריים public interface MyInterface { public.
Cross Validation False Negatives / Negatives
מבוא למדעי המחשב תרגול 2 שעת קבלה : יום שני 11:00-12:00 דוא " ל :
תכנות תרגול 4 שבוע : לולאות while לולאות while while (condition) { loop body } במקרה של קיום התנאי מתבצע גוף הלולאה ברגע שהתנאי לא מתקיים נצא.
סוגי מידע / משתנים ד " ר אבי רוזנפלד. סוגאורךטווח Boolean1 Bit0,1 Byte1 byte0-255 Char 2 bytes תו Decimal16 bytes0 through +/-79,228,162,514,264,337,593,543,950,335.
מבוא למדעי המחשב תרגול 8 - מחרוזות שעת קבלה : יום שני 11:00-12:00 דוא " ל :
תכנות תרגול 6 שבוע : תרגיל שורש של מספר מחושב לפי הסדרה הבאה : root 0 = 1 root n = root n-1 + a / root n-1 2 כאשר האיבר ה n של הסדרה הוא קירוב.
מבני בקרה מבוא לתכנות למנע " ס - שבוע מספר 3 - מאיר קומר - סמסטר ב ' - תשס " ו הסתעפות “ אם השמאל ואימנה ואם הימין ואשמאילה ”
מערכים מבוא לתכנות למנע"ס - שבוע מספר 8 - מאיר קומר - סמסטר ב' - תשס"ו והנה בעיה כתוב תוכנית אשר תקלוט 36 מספרים ותדפיס כמה מתוכם גדולים יותר מהממוצע.
מבוא כללי למדעי המחשב תרגול 3. לולאות while לולאות while while (condition) { loop body } במקרה של קיום התנאי מתבצע גוף הלולאה ברגע שהתנאי לא מתקיים נצא.
מערכים עד היום כדי לייצג 20 סטודנטים נאלצנו להגדיר עד היום כדי לייצג 20 סטודנטים נאלצנו להגדיר int grade1, grade2, …, grade20; int grade1, grade2, …, grade20;
11 Introduction to Programming in C - Fall 2010 – Erez Sharvit, Amir Menczel 1 Introduction to Programming in C תרגול
Session 08: Architecture Controllers or Managers Graphical User Interface (GUI) FEN AK - IT Softwarekonstruktion.
Programming Interface Controls ISYS 350. User Interface Controls Form MessageBox Common Controls: –Button, TextBox, MaskedTextBox, List Box, Option Button,
By Szeto CYVisual C# Text form1Clock (label1) lblHH00 (label2) lblMM00 (label3) lblSS00 label4: label5: timer1Interval 500 Enabled true 按照下表,更改各控制項.
Intro to More Controls in C#. C# Demonstration We already touched on labels and buttons Ad-hoc demo of controls – Textboxes Multiline – Checkbox – Radiobutton.
Lecture 16: Multithreaded Programming. public partial class Form1 : Form { Thread ct; Thread rt; public static int circle_sleep = 0; public static int.
Sample Application Multi Layered Architecture (n-tier): –Graphical User Interface (GUI): Forms, components, controls The Visual Designer in Visual Studio.
Command Object’s ExecuteNonQuery Method ISYS 512.
Programming Interface Controls ISYS 350. User Interface Controls Form MessageBox Common Controls: –Button, TextBox, MaskedTextBox, List Box, Option Button,
Introduction to Windows Forms Application By N Hanumantha Rao MCA By N Hanumantha Rao MCA.
Architecture Multi Layered Architecture (n-tier): Application: Model Controllers Database Access Graphical User Interface (GUI): Forms, components, controls.
DataGridView. Displaying data in a tabular format is a task you are likely to perform frequently. The DataGridView control is designed to be a complete.
מבנה נתונים ואלגוריתמים ) לשעבר - עיבוד מידע( ד"ר אבי רוזנפלד ד"ר אריאלה ריכרדסון.
שיתוף PDT בין חוטים PDT Thread A Process Descriptor File Object 1 File Object 2 File 1 File 2 pthread_create Thread B Process Descriptor ה PDT משותף לכל.
Programming Interface Controls ISYS 350. User Interface Controls Form MessageBox Common Controls: –Button, TextBox, MaskedTextBox, List Box, Option Button,
Programming Interface Controls ISYS 350. User Interface Controls Form MessageBox Common Controls: –Button, TextBox, MaskedTextBox, List Box, Option Button,
Array, ArrayList and List ISYS 350. Array An array allows you to store a group of items of the same type together. Processing a large number of items.
Windows form programming. namespace MyNamespace { public class MyForm : System.Windows.Forms.Form { public MyForm() { this.Text = "Hello Form"; }
מספרים אקראיים ניתן לייצר מספרים אקראיים ע"י הפונקציה int rand(void);
Expression ISYS 350.
Decision Structure ISYS 350.
Array ISYS 350.
Decision Structure - 1 ISYS 350.
Loops ISYS 350.
Expression ISYS 350.
Programming Interface Controls
Programming Interface Controls
Array ISYS 350.
البرمجة بلغة فيجول بيسيك
Array ISYS 350.
Decision Structure - 1 ISYS 350.
مراحل كتابة البرنامج بلغة فيجول بيسك ستديو
Array ISYS 350.
Work with Data and Decision Structure
Loops ISYS 350.
Array ISYS 350.
תוכנה 1 תרגול 13 – סיכום.
עקרונות בסיסיים בתכנות Visual Basic
Expression ISYS 350.
Decision Structures ISYS 350.
Expression ISYS 350.
Self Study GUI Properties & Events
Decision Structure - 1 ISYS 350.
Web Service.
Loops ISYS 350.
Loops ISYS 350.
Expression ISYS 350.
Decision Structure - 1 ISYS 350.
Expression ISYS 350.
BMI Form1 Body Mass Index textBox3-4 (readonly) trackBar1
Programming Interface Controls
AB form1 Multiplication textBox1 12 textBox2 34 textBox3
Final Revision sheet- term2
Final Revision sheet- term2
label1 Name label2 Time (0-23) textBox1 textBox2 textBox3 button1
P(1) = P(2) = P(3) = P(4) = P(5) = 0.166
Command Object’s ExecuteNonQuery Method
Presentation transcript:

מבוא לתכנות בWINDOWS ב#C ד"ר אבי רוזנפלד

בניית הטופס ב#C

בניית הטופס

הוספת אובייקטים תעבוד עם הTOOLBAR והמאפיינים

שינוי המאפיינים אחרי הEVENT .SHOW .HIDE .TEXT .ForeColor = Color.???

דוגמא

הקוד של הEVENT using ... namespace WindowsFormsApplication1 { public partial class Form1 : Form public Form1() InitializeComponent(); } private void button1_Click(object sender, EventArgs e) MessageBox.Show("Hello World","Title here!"); button1.Hide(); private void button2_Click(object sender, EventArgs e) textBox1.Text = "Hi there!"; button1.Show(); button1.ForeColor = Color.Green;

הטופס...

הקוד... namespace WindowsFormsApplication1 { public partial class Form1 : Form public Form1() InitializeComponent(); } private void button1_Click(object sender, EventArgs e) String word1 = textBox1.Text; String word2 = textBox2.Text; textBox3.Text = word1 + " added to " + word2 + " is " + word1+word2; MessageBox.Show(word1 + word2); //works! private void button2_Click(object sender, EventArgs e) // Double number1 = textBox1.Text; // "error cannot convert type string to double Double number1 = double.Parse(textBox4.Text); //converts! Double number2 = double.Parse(textBox5.Text); textBox6.Text = number1 + " added to " + number2 + " is " + number1 + number2; // MessageBox.Show(number1 + number2); Doesn't work! //MessageBox.Show((number1 + number2).ToString()); // a bit confusing... Double temp = number1 + number2; MessageBox.Show(temp.ToString());

קלט / פלט עם לוגיקה namespace WindowsFormsApplication1 { public partial class Form1 : Form public Form1() InitializeComponent(); } private void button1_Click(object sender, EventArgs e) int x = int.Parse(textBox1.Text); int y = int.Parse(textBox2.Text); if (x > y) textBox3.Text=(x + " is bigger than " + y); else if (x<y) textBox3.Text = (y + " is bigger than " + x); else textBox3.Text = ("They are the same!");

הטופס...

namespace WindowsFormsApplication1 { public partial class Form1 : Form public Form1() InitializeComponent(); } private void button1_Click(object sender, EventArgs e) int size = int.Parse(textBox1.Text); listBox1.Items.Clear(); //clears the listBox for (int i = 0; i < size; i++) string star = ""; for (int j = 0; j <= i; j++) // listBox1.Items.Add("*"); won't work! star += "*"; listBox1.Items.Add(star); // This will work! listBox2.Items.Add("Hi"); ListBox

הטופס...

CheckBox public partial class Form1 : Form { public Form1() InitializeComponent(); } private void button2_Click(object sender, EventArgs e) Application.Exit(); private void button1_Click(object sender, EventArgs e) int total = 0; if (checkBox1.Checked == true) total += 10; if (checkBox2.Checked == true) total += 5; if (checkBox3.Checked == true) total += 20; string temp = total.ToString(); textBox1.Text = temp;

הטופס

RadioBox namespace WindowsFormsApplication1 { public partial class Form1 : Form public Form1() InitializeComponent(); } private void button1_Click(object sender, EventArgs e) if (radioButton1.Checked == true) textBox1.Text = "Good"; if (radioButton2.Checked == true) textBox1.Text = "Better"; if (radioButton3.Checked == true) textBox1.Text = "Best"; if (radioButton4.Checked == true) textBox1.Text = "We love Shas!";

סיכום בתכנות אירועים, יש צורך לשאול: מה יהיה האירוע (ומה יש בטופס כדי לקלוט אותו) מה יהיה התוצאה (ואיפה זה יופיע) מה הקוד מאחורי התוצאה סוגי אובייקים: LABEL לפלט או קלט (אבל בד"כ פלט) MsgBox , ListBox לפלט TextBox לקלט או פלט (אבל בד"כ קלט) כפתור להפעיל אירוע

תרגיל #1 לכתוב תכנית הקולטת סיסמה מהמשתמש. אם המשתמש הקיש את הסיסמה "BASIC" יש להציג את ההודעה "Welcome" ולסיים. אם המשתמש שגה בהקשת הסיסמה יש להציג את ההודעה "Wrong, Please try again". אם המשתמש שגה 3 פעמים (ברציפות) יש להציג את ההודעה "Wrong, cant continue. bye". כמה משתמים יש? איפה הם שמורים?

תרגיל #2 תרגיל #2: כתוב תוכנה הקולטת ערך אחד מתוך 5 RADIOBOX. באמצעות IF תפלוט משהו לכל אופציה (לא משנה מה).