Busy. Please wait.
or

show password
Forgot Password?

Don't have an account?  Sign up 
or

Username is available taken
show password

why


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
We do not share your email address with others. It is only used to allow you to reset your password. For details read our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.
Don't know
Know
remaining cards
Save
0:01
To flip the current card, click it or press the Spacebar key.  To move the current card to one of the three colored boxes, click on the box.  You may also press the UP ARROW key to move the card to the "Know" box, the DOWN ARROW key to move the card to the "Don't know" box, or the RIGHT ARROW key to move the card to the Remaining box.  You may also click on the card displayed in any of the three boxes to bring that card back to the center.

Pass complete!

"Know" box contains:
Time elapsed:
Retries:
restart all cards
share
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

Chapter 14

Graphical User Interfaces with Windows Forms: Part 1

TermDefinition
Components GUI controls. GUI's are built from GUI controls
1. Some Basic GUI Controls 1. Control[Label]..Description[Displays images or uneditable text]... 2. Control[TextBox]..Description[Enables the user to enter data via the keyboard. It can also be used to display editable or uneditable text]...
2. Some Basic GUI Controls 3. Control[Button]..Description[Triggers an event when clicked with the mouse]... 4. Control[CheckBox]..Description[Specifies an option that be selected(checked) or unselected(not checked)]...
3. Some Basic GUI Controls 5. Control[ComboBox]..Description[Provides a drop-down list of items from which the user can make a selection either by clicking an item in the list or by typing in a box]...
4. Some Basic GUI Controls 6. Control[ListBox]..Description[Provides a list of items from which the user can make a selection by clicking one or more items]... 7. Control[Panel]..Description[A container in which controls can be placed and organized]...
5. Some Basic GUI Controls 8. Control[NumericUpDown]..Description[Enables the user to select from a range of numeric input values]
Windows Forms One library that can be used to create GUIs
Form A graphical element that appears on your computer's desktop; it can be a dialog, a window, or an MDI window(multiple document interface window). A Form is a container for controls
Component An instance of a class that implements the IComponent interface, which defines the behaviors that components must implement, such as how the component is loaded
Control Has a graphical representation at runtime, such as a Button or Label.
Pointer Item The icon at the top of the ToolBox list. Allows you to deselect a control or component. When the Pointer item is selected, you cannot accidentally add a new control to the Form
Active Window When there are several windows on the screen, the active window is the frontmost an has a highlighted title bar. A window become active when the user clicks somewhere inside it. The active window is said to "have the focus."
1. Using Toolbox Items When you drag items from the Toolbox onto the Form, Visual Studio generates code that creates the object and sets its basic properties. This code is updated when the control or component's properties are modified in the IDE.
2. Using Toolbox Items Removing a control or component from the Form deletes the corresponding generated code.
Partial Classes Classes that are split among multiple files and assembled into a single class by the compiler. When using Toolbox items, the IDE maintains the generated code in a separate file using partial classes
1. Common Form Properties 1. Property[AcceptButton]..Description[Default Button that's clicked for you when you press Enter]... 2. Property[AutoScroll]..Description[bool value(false by default) that allows or disallows scrollbars when needed]...
2. Common Form Properties 3. Property[CancelButton]..Description[Button that's clicked when the Escape key is pressed]... 4. Property[FormBorderStyle]..Description[Border style for the Form(Sizable by default)]...
3. Common Form Properties 5. Property[Font]..Description[Font of text displayed on the Form, and the default font for controls added to the Form]... 6. Property[Text]..Description[Text in the Form's title bar]
1. Common Form Methods 1. Method[Close]..Description[Closes a Form and releases all resources, such as the memory used for the Form's contents. A closed Form cannot be reopened]... 2. Method[Hide]..Description[Hides the Form, but does not destroy or release its resources]...
2. Common Form Methods 3. Method[Show]..Description[Displays a hidden Form]
Common Form Event 1. Event[Load]..Description[Occurs before a Form is displayed to the user. You'll learn about events and event-handling in the next section]
Event Handler A method that performs a task in response to an event
Event Handling The overall process of responding to events
Class's Fully Qualified Class Name A combination of a class's namespace name, a dot(.), and the class name
Event Sender The control that generates an event
Event-Handling Method Known as an event handler. Responds to a particular event that a control generates. When the vent occurs, the event sender calls is event handler to perform a task(to "handle the event")
Delegates Event handlers are connected to a control's events via special objects called delegates. A delegates type declaration specifies the signature of a method - in event handling, the signature specifies the return type and argument for an event handler
GUI Control's Predefined Delegates GUI controls have predefined delegates that correspond to every event they can generate. For example, the delegate for a Button's Click event is of type EventHandler(namespace System)
1. Delegate Keyword Ex: public delegate void EventHandler(object sender, EventArgs e);
2. Delegate Keyword This uses the delegate keyword to declare a delegate type named EventHandler, which can hold references to methods that return void and receive two parameters - one of type object(the event sender) and one of type EventArgs
Multicast Event Delegates Event delegates are multicast - they represent a set of delegate objects that all have the same signature. Multicast delegates enable several methods to be called in response to a single event
Event Multicasting The process in which, when an event occurs, the event sender calls ever method referenced by the multicast delegate. Event delegates derive from class MulticastDelegate, which derives from class Delegate(both from namespace System)
Default Event The event that's most frequently used with that control. When you double click a control on the Form to create its event handler, an event handler for a control's default event is created
Class Control Controls derived from class Control
1. Class Control Common Properties 1. Property[BackColor]..Description[The control's background color]... 2. Property[BackgroundImage]..Description[The control's background image]...
2. Class Control Common Properties 3. Property[Enabled]..Description[Specifies whether the control is enabled(if the user can interact with it). Typically, portions of a disabled control appear "grayed out" as a visual indication to the user that the control is disabled]...
3. Class Control Common Properties 4. Property[Focused]..Description[Indicates whether the control has the focus(only available at runtime)]... 5. Property[Font]..Description[The Font used to display the control's text]...
4. Class Control Common Properties 6. Property[ForeColor]..Description[The control's foreground color. This usually determines the color of the text in the Text property]...
5. Class Control Common Properties 7. Property[TabIndex]..Description[The tab order of the control. When the Tab key is pressed, the focus transfers between controls based on the tab order. You can set this order using VIEW > Tab Order]...
6. Class Control Common Properties 8. Property[TabStop]..Description[If true, a user can give focus to this control via the Tab key]... 9. Property[Text]..Description[The text associated with the control. The location and appearance of the text vary depending on the type of control]...
7. Class Control Common Properties 10. Property[Visible]..Description[Indicates whether the control is visible]
1. Class Control Common Methods 1. Method[Hide]..Description[Hides the control(sets the Visible property to false)]... 2. Method[Select]..Description[Acquires the focus. This method transfers the focus to a control and makes it the active control]...
2. Class Control Common Methods 3. Method[Show]..Description[Shows the control(sets the Visible property to true)]
Anchoring Controls Causes controls to remain at a fixed distance from the sides of the container even when the container is resized. Anchoring enhances the user experience
Docking Controls Attaches a control to a container such that the control stretches across an entire side or fills an entire area
Form Padding Property Forms have a Padding property that specifies the distance between the docked controls and the Form edges. This property specifies four values(one for each side), and each value is set to 0 by default
1. Control Layout Properties 1. Property[Anchor]..Description[Causes a control to remain at a fixed distance from the side's of the container even when the container is resized]...
2. Control Layout Properties 2. Property[Dock]..Description[Allows a control to span on e side of its container or to fill the remaining space in the container]...
3. Control Layout Properties 3. Property[Padding]..Description[Sets the space between a container's edges and docked controls. The default is 0, causing the control to appear flush with the container's sides]...
4. Control Layout Properties 4. Property[Location]..Description[Specifies the location(as a set of coordinates) or the upper-left corner of the control, in relation to its container's upper-left corner]...
5. Control Layout Properties 5. Property[Size]..Description[Specifies the size of the control in pixels as a Size object, which has properties Width and Height]... 6. Property[MinimumSize and MaximumSize]..Description[Indicates minimum and maximum size of a Control, respectively]
Properties MinimumSize and MaximumSize The minimum and maximum Form(or other control) sizes can be set via these properties. Both are of type Size, which has properties Width and Height to specify the size of the Form. Allow you to design the GUI layout for a given size range
Setting a Fixed Form Size To set a Form to a fixed size(where the Form cannot be resized by the user), set its minimum and maximum size to the same value
Snap Lines Blue lines that appear to help you position the control with respect to others and the Form's edges when you drag a control across a Form
FORMAT Menu Contains options for modifying your GUI's layout. This menu does not appear in the IDE unless you select one or more controls in design view. Enables you to modify the space between controls or to center a control on the Form
1. Common Label Properties 1. Property[Font]..Description[The font of the text on the Label]... 2. Property[Text]..Description[The text on the Label]...
2. Common Label Properties 3. Property[TextAlign]..Description[The alignment of the Label's text on the control - horizontally(left, center, or right) and vertically(top, middle, or bottom)]. The default is top, left
Textbox A textbox(class TextBox) is an area in which either text can be displayed by your a program or the user can type text via the keyboard
Password TextBox A TextBox that hides the information entered by the user. As the user types characters, the password TextBox masks the user input by displaying a password character
UseSystemPasswordChar If you set the property UseSystemPasswordChar to true, the TextBox becomes a password TextBox
1. Common TextBox Properties 1. Property[AcceptsReturn]..Description[If true in a multiline TextBox, pressing Enter in the TextBox creates a new line. If false(the default), pressing Enter is the same as pressing the default Button on the Form.
2. Common TextBox Properties The default Button is the one assigned to a Form's AcceptButton property]... 2. Property[Multiline]..Description[If true, the TextBox can span multiple lines. The default value is false]...
3. Common TextBox Properties 3. Property[ReadOnly]..Description[If true, the TextBox has a gray background, and its text cannot be edited. The default value is false]...
4. Common TextBox Properties 4. Property[ScrollBars]..Description[For multiline textboxes, this property indicates which scrollbars appear(None - the default, Horizontal, Vertical, or Both)]...
5. Common TextBox Properties 5. Property[Text]..Description[The TextBox's text content]... 6. Property[UseSystemPasswordChar]..Description[When true, the TextBox becomes a password TextBox, and the system specified character masks each character the user types]
Common TextBox Event 1. Event[TextChanged]..Description[Generated when the text changed in a TextBox(when the user adds or deletes characters). When you double click the TextBox control in Design mode, an empty event handler for this event is generated]
Button A button is a control that the user click to trigger a specific action or to select an option in a program. A program can use several types of buttons, such as checkboxes and radio buttons
ButtonBase Defines common buttons features. All the button classes derived from class ButtonBase(namespace System.Windows.Forms)
1. Common Button Properties 1. Property[Text]..Description[Specifies the text displayed on the Button face]... 2. Property[FlatStyle]..Description[Modifies a Button's appearance - Flat(displayed without 3D appearance), Popup(appears flat until user moves mouse pointer over it),
2. Common Button Properties Standard(appears 3D), and System, where the Button's appearance is controlled by the operating system. The default value is Standard
Common Button Event 1. Event[Click]..Description[generated when the user clicks the Button. When you double click a Button in design view, an empty event handler for this event is created]
GroupBoxes and Panels Arrange controls on a GUI. Are typically used to group several controls of similar functionality or several controls that are related in a GUI
Common GroupBox Properties 1. Property[Controls]..Description[The set of controls that the GroupBox contains]... 2. Property[Text]..Description[Specifies the caption text displayed at the top of the GroupBox]
1. Common Panel Properties 1. Property[AutoScroll]..Description[Indicates whether scrollbars appear when the Panel is too small to display all of its controls. The default value is false]...
2. Common Panel Properties 2. Property[BorderStyle]..Description[Sets the border of the Panel. The default value is None; other options are Fixed3D and FixedSingle]... 3. Property[Controls]..Description[The set of controls that the Panel contains]
State Buttons C# has two types of state buttons that can be in the on/off or true/false states - CheckBoxes and RadioButtons. Like class Button, classes CheckBox and RadioButton are derived from class ButtonBase
CheckBox A small square that either is blank or contains a check mark. When the user clicks it to select it, a check mark appears in the box. If the user clicks it again to deselect it, the check mark is removed
1. Common CheckBox Properties 1. Property[Appearance]..Description[By default, this property is set to Normal, and the CheckBox displays as a traditional checkbox. If it's set to Button, the CheckBox displays as a Button that looks pressed when the CheckBox is checked]...
2. Common CheckBox Properties 2. Property[Checked]..Description[Indicates whether the CheckBox is checked(contains a check mark) or unchecked(blank). This property returns a bool value. The default is false(unchecked)]...
3. Common CheckBox Properties 3. Property[CheckState]..Description[Indicates whether the CheckBox is checked or unchecked with a value from the CheckState enumeration(Checked, Unchecked, or Indeterminate).
4. Common CheckBox Properties Indeterminate is used when it's unclear whether the state should be Checked or Unchecked. When CheckState is set to Indeterminate, the CheckBox is usually shaded]...
5. Common CheckBox Properties 4. Property[Text]..Description[Specifies the text displayed to the right of the CheckBox]... 5. Property[ThreeState]..Description[When this property is ture, the CheckBox has three states - checked, unchecked, and indeterminate.
6. Common CheckBox Properties By default, this property is false and the CheckBox has only two states - checked and unchecked]...
1. Common CheckBox Events 1. Property[CheckedChanged]..Description[Generated when the Checked or CheckState property changes. This is a CheckBox's default event. When a user double clicks the CheckBox control in design view, an empty handler for this even it generated]...
2. Common CheckBox Events 2. Property[CheckStateChanged]..Description[Generated when the Checked or CheckState property changes]
Changing a Label's Font Style To change a Label's font style, set its Font property to a new Font object. The Font constructor that we use here takes the current font and new style as arguments. Ex: label.Font = new Font(label.Font.label.Font.Style ^ Fontstyle.Italic);
FontStyle Enumerations The style of text is specified with a member of the FontStyle enumeration, which contains Regular, Bold, Italic, Strikeout(text with line through it), and Underline.
Font Object's Style Property Is read-only, so it can be set only when the Font object is created
Bitwise Operators Operators that perform manipulation on bits on information. Styles can be combined with bitwise operators
RadioButtons Have two states - selected and deselected. Normally appear as a group, in which only one RadioButton can be selected at a time. Selecting one RadioButton in the group forces all the other to be deselected. Represent a set of mutually exclusive options
Set of Mutually Exclusive Options A set in which multiple options cannot be selected at the same time
Common RadioButton Properties 1. Property[Checked]..Description[Indicates whether the RadioButton is checked]... 2. Property[Text]..Description[Specifies the RadioButton's text]
Common Event 1. Event[CheckedChanged]..Description[Generated every time the RadioButton is checked or unchecked. When you double click a RadioButton control in design view, an empty event handler for this event is generated]
PictureBox Displays an image
1. Common PictureBox Properties 1. Property[Image]..Description[Sets the image to display in the PictureBox]... 2. Property[SizeMode]..Description[Enumeration that controls image sizing and positioning. Values are Normal(default), StretchImage, AutoSize, CenterImage, and Zoom.
2. Common PictureBox Properties Normal places the image in the PcitureBox's top-left corner, and CenterImage puts the image in the middle. These two options truncate the image if it's too large. StretchImage resizes the image to fit in the PictureBox.
3. Common PictureBox Properties AutoSize resizes the PictureBox to hold the image. Zoom resizes the image to fit the PictureBox but maintains the original aspect ratio
Common PictureBox Event 1. Event[Click]..Description[Occurs when the user clicks a control. When you double click this control in the designer, an event handler is generated for this event]
1. Adding Images to Projects as Resources 1. After creating your project, right click the project's Properties node in the Solution Explorer and select Open to display the project's properties... 2. From the tabs on the left, click the Resources tab...
2. Adding Images to Projects as Resources 3. At the top of the Resources tab, click the down arrow next to Add Resource and select Add Existing File to display the Add existing file to resources dialog... 4. Locate the image files you wish to add as resources and click the Open button...
3. Adding Images to Projects as Resources 5. Save your project
Resources Class A project's resources are stored in its Resources class(or the project's Properties namespace)
ResourceManager The Resources class contains a ResourceManager object for interacting with the resources programmatically
GetObject Method To access an image, you can use the method GetObject, which takes as an argument the resource name as it appears in the Resources tab and returns the resource as an Object.
GetObject Method Example Ex: imagePictureBox.Image = (Image)(Properties.Resources.ResourceManager.GetObject(string.Format("image{0}", imageNum)));
Tool Tips The helpful text that appears when the mouse hovers over an item in a GUI. Recall that the tool tips displayed in Visual Studio help you become familiar with the IDE's features and serve as useful reminders for each toolbar icon's functionality
1. Common ToolTip Properties 1. Property[AutoPopDelay]..Description[The amount of time(in milliseconds) that the tool tip appears while the mouse is over a control]...
2. Common ToolTip Properties 2. Property[InitialDelay]..Description[The amount of time(in milliseconds) that a mouse must hover over a control before a tool tip appears]...
3. Common ToolTip Properties 3. Property[ReshowDelay]..Description[The amount of time(in milliseconds) between which two different tool tips appear(when the mouse is moved from one control to another)]
Common ToolTip Event 1. Event[Draw]..Description[Raised when the tool tip is displayed. This event allows programmers to modify the appearance of the tool tip]
Component Tray The region below the Form in Design mode. When you add a ToolTip component from the ToolBox, it appears in the component try
NumericUpDown Control This control appears as a TextBox, with two small Button on the right side - one with an up arrow and one with a down arrow. A user can type numeric values into this control or click the up and down arrows to increase or decrease the value in the control
1. Common NumericUpDown Properties 1. Property[DecimalPlaces]..Description[Specifies how many decimal places to display in the control]... 2. Property[Increment]..Description[Specifies how much the current number in the control changes when the user clicks control's up and down arrows]...
2. Common NumericUpDown Properties 3. Property[Maximum]..Description[Largest value in the control's range]... 4. Property[Minimum]..Description[Smallest value in the control's range]...
3. Common NumericUpDown Properties 5. Property[UpDownAlign]..Description[Modifies the alignment of the up and down Buttons on the NumericUpDown control. This property can be used to display these Buttons either to the left or to the right of the control]...
4. Common NumericUpDown Properties 6. Property[Value]..Description[The numeric value currently displayed in the control]
Common NumericUpDown Event 1. Event[ValueChanged]..Description[This event is raised when the value in the control is changed. This is the default event for the NumericUpDown control]
Class MouseEventArgs For most mouse events, information about the event is passed to the event-handling method through an object of this class. Contains information related to mouse event, such as mouse pointer's x- and y-coord, mouse button pressed, and # times mouse clicked
MouseEventHandler The delegate used to create the mouse event handlers. Each mouse-event-handler method for these events requires an object and a MouseEventArgs objects as arguments
1. Mouse Events with Event Argument of Type EventArgs 1. Event[MouseEnter]..Description[Mouse cursor enters the control's boundaries]... 2. Event[MouseHover]..Description[Mouse cursor hovers within the control's boundaries]...
2. Mouse Events with Event Argument of Type EventArgs 3. Event[MouseLeave]..Description[Mouse cursor leaves the control's boundaries]
1. Mouse Events with Event Argument of Type MouseEventArgs 1. Event[MouseDown]..Description[Mouse button is pressed while the mouse cursor is within a control's boundaries]... 2. Event[MouseMove]..Description[Mouse cursor is moved while in the control's boundaries]...
2. Mouse Events with Event Argument of Type MouseEventArgs 3. Event[MouseUp]..Description[Mouse button is released when the cursor is over the control's boundaries]... 4. Event[MouseWheel]..Description[Mouse wheel is moved while the controls has the focus]...
1. Class MouseEventArgs Properties 1. Property[Button]..Description[Specifies which mouse button was pressed(Left, Right), Middle, or None]... 2. Property[Clicks]..Description[The number of times that the mouse button was clicked]...
2. Class MouseEventArgs Properties 3. Property[X]..Description[The x-coordinate within the control where the event occurred]... 4. Property[Y]..Description[The y-coordinate within the control where the event occurred]
Key Events Occur when keyboard keys are pressed and released
Keys Enumeration Provides constants that specify the various keys on a keyboard
Key Events with Event Arguments of Type KeyEventArgs 1. Event[KeyDown]..Description[Generated when a key is initially pressed]... 2. Event[KeyUp]..Description[Generated when a key is released]
Key Events with Event Arguments of Type KeyPressEventArgs 1. Event[KeyPress]..Description[Generated when a key is pressed. Raised after KeyDown and before KeyUp]
Class KeyPressedEventArgs Properties 1. Property[KeyChar]..Description[Returns the ASCII character for the key pressed]
1. Class KeyEventArgs Properties 1. Property[Alt]..Description[Indicates whether the Alt key was pressed]... 2. Property[Control]..Description[Indicates whether the Ctrl key was pressed]... 3. Property[Shift]..Description[Indicates whether the Shift key was pressed]...
2. Class KeyEventArgs Properties 4. Property[KeyCode]..Description[Returns the key code for the key as a value from the Keys enumeration. This does not include modifier-key information. It's used to test for a specific key]...
3. Class KeyEventArgs Properties 5. Property[KeyData]..Description[Returns the key code for a key combined with a modifier information as a Keys value. this property contains all information about the pressed key]...
4. Class KeyEventArgs Properties 6. Property[KeyValue]..Description[Returns the key code as an int, rather than as a value from the Keys enumeration. This property is used to obtain a numeric representation of the pressed key. The int value is known as a Windows virtual key code]...
5. Class KeyEventArgs Properties 7. Property[Modifiers]..Description[Returns a Keys value indicating any pressed modifier keys(Alt, Ctrl, and Shift). This property is used to determine modifier-key information only]
Created by: TimC#Programming