CSCI 3328 Object CSCI 3328 Object Oriented Programming in Oriented Programming in C# C# Chapter 10: Graphical Chapter 10: Graphical User Interfaces with User Interfaces with Windows Forms Windows Forms 1 Xiang Lian The University of Texas – Pan American Edinburg, TX 78539 [email protected]
37
Embed
CSCI 3328 Object Oriented Programming in C# Chapter 10: Graphical User Interfaces with Windows Forms 1 Xiang Lian The University of Texas – Pan American.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
CSCI 3328 Object Oriented CSCI 3328 Object Oriented Programming in C# Programming in C#
Chapter 10: Graphical User Chapter 10: Graphical User Interfaces with Windows FormsInterfaces with Windows Forms
• Anchoring causes controls to remain at a fixed distance from the sides of the container, even when the container is resized– Darkened bar indicate the container’s sides to which the
control is anchored
11
Dock Property and Other Properties
12
• Dock
• Other properties– Location– Size– MaximumSize– MinimumSize
Labels, TextBoxes and Buttons
• A Label displays text that the user cannot directly modify
• A TextBox is an area in which either text can be displayed by a program or user can type text via keyboard– A password TextBox
• Set UseSystemPasswordChar to true
• A Button is a control that the user clicks to trigger a specific action or to select an option in a program
13
Common Properties/Events of Labels, TextBoxes and Buttons
• Label– Font, Text, TextAlign
• TextBox– AcceptReturn
• If true in a multiline TextBox, pressing Enter in the TextBox creates a new line
• Properties of class MouseEventArgs– Button (Left, Right, Middle or none button of the mouse)– Clicks (number of clicking times)– X– Y
22
Keyboard Events• Event KeyEventArgs
– KeyDown– KeyUp
• Event KeyPressEventArgs– KeyPress
• Properties of class KeyPressEventArgs– KeyChar– Handled (whether the event was handled)
• Properties of class KeyEventArgs– Alt (whether Alt key was pressed)– Control (whether Ctrl key was pressed)– Shift (whether Shift key was pressed)– Handled (whether the event was handled)
23
Menus
• Main menu bar– Type menu name
– Place & character before a letter to underline it• E.g., &File
• Effect: File (you can press Alt+F keys to select file menu)