Sunteți pe pagina 1din 29

DR ATIF SHAHZAD

IE-322

Computer Applications
LECTURE #10 in Industrial Engg.-I
Computer Applications in
Industrial Engg.-I

IE322
Dr. Atif Shahzad

8/12/2018
…Recap
What we will see…

Adding Controls & Setting


Combo Picture
Properties

Connecting Forms
• Calling Forms
Setting properties for Check Picture using Resources

Setting Initial Form Setting properties for Radio List


Dr. Atif Shahzad

8/12/2018
More on Classes

IE322
Windows Forms
GUI
System.Windows.Forms
Active window
A form as a container
Toolbox
Controls
Properties
Dr. Atif Shahzad

8/12/2018 6
Windows Forms App
Dr. Atif Shahzad

8/12/2018 7
Windows Forms App
Dr. Atif Shahzad

8/12/2018 8
Adding Controls to Form
Dr. Atif Shahzad

8/12/2018 9
Event Handling
GUIs are event driven
Event Handler
Syntax of event handler
object sender
Eventargs e
MessagBox.Show(“Hello!”);
Dr. Atif Shahzad

8/12/2018 10
Visual Studio Generated Code
Auto-generated code
Designer.cs of a Form
InitializeComponent(); //called when Form is created
Dr. Atif Shahzad

8/12/2018 11
Few common Control Properties &
Layout
Name
BackColor
Enabled
Focused
Font
ForeColor
Text
Visible
Dr. Atif Shahzad

8/12/2018 12
Labels
Font
Text
textAlign
UseSystemPasswordChar
Dr. Atif Shahzad

8/12/2018 13
Labels
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{
label1.Text = "This is my first Lable";
label1.BorderStyle = BorderStyle.FixedSingle;
label1.TextAlign = ContentAlignment.MiddleCenter;
}
Dr. Atif Shahzad

}
}
8/12/2018 14
Textboxes
Text
Dr. Atif Shahzad

8/12/2018 15
Buttons

private void btnEXIT_Click(object sender, EventArgs e)


{
Close();
}
Dr. Atif Shahzad

8/12/2018 16
GroupBoxes
Dr. Atif Shahzad

8/12/2018 17
Radiobox

private void rdoGreen_CheckedChanged(object sender, EventArgs e)


{
if (rdoGreen.Checked == true)
rdoGreen.ForeColor = Color.FromName("green");
}
Dr. Atif Shahzad

8/12/2018 18
Checkbox
string msg = "";

if (checkBox1.Checked) == true)
{
msg = "IE322";
}
Dr. Atif Shahzad

8/12/2018 19
Combobox
Dr. Atif Shahzad

8/12/2018 20
Combobox
Dr. Atif Shahzad

8/12/2018 21
Combobox
How can you remove
the last item from a
combobox when you
don’t know how many
items are in combobox?
Dr. Atif Shahzad

8/12/2018 22
Picturebox
AutoSize - Sizes the picture box to the image.
CenterImage - Centers the image in the picture box.
Normal - Places the upper-left corner of the image at upper
left in the picture box
StretchImage - Allows you to stretch the image in code
Dr. Atif Shahzad

8/12/2018 23
Picturebox (Method 1)
Dr. Atif Shahzad

8/12/2018 24
Picturebox (Method 2)
Dr. Atif Shahzad

8/12/2018 25
Picturebox (Method 2)
Dr. Atif Shahzad

8/12/2018 26
Rest is on Visual Studio
For the rest of this lecture, Please refer to
the Code files demonstrated in the class
and uploaded on BB
Dr. Atif Shahzad

8/12/2018 27
NEVER hesitate to
contact should you
have any question
Dr. Atif Shahzad
Dr. Atif Shahzad

8/12/2018 29

S-ar putea să vă placă și