1 Graphical User Interfaces Part 2 Outline ListBoxes and CheckedListBoxes ListBoxes CheckedListBoxes ComboBoxes.

Slides:



Advertisements
Similar presentations
Microsoft Visual Basic: Reloaded Chapter Seven More on the Repetition Structure.
Advertisements

Microsoft Visual C#.NET: From Problem Analysis to Program Design1 Chapter 9 Programming Based on Events Microsoft Visual C#.NET: From Problem Analysis.
C# Programming: From Problem Analysis to Program Design1 9 Programming Based on Events.
1 Lab6 Lab6 ComboBox Control Properties, Methods and Events.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 03.
Programming Based on Events
VB Default Controls List Box, Combo Box
Graphical User Interface (GUI) A GUI allows user to interact with a program visually. GUIs are built from GUI components. A GUI component is an object.
ListBoxes The list box control allows the user to view and select from multiple items in a list. CheckedListBox control extends a list box by including.
Group Boxes and Panels Arrange components on a GUI Buttons and etc. can be placed inside a group box or panel. All these buttons move together when the.
Programming Based on Events
List-based Controls. Slide 2 Introduction There are several controls that work with lists ComboBox ListBox CheckedListBox.
CA 121 Intro to Programming Tariq Aziz and Kevin Jones GUI Programming in Visual Studio.NET Chapter 3 Tariq Aziz and Kevin Jones.
Compunet Corporation Programming with Visual Basic.NET GUI Chapter 3 Week 13 Tariq Aziz and Kevin Jones.
Chapter 8 Using Repetition with Loops and Lists. Class 8: Loops and Lists Write Do loops to execute statements repeatedly Write For loops to execute statements.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Tutorial 7: Sub and Function Procedures1 Tutorial 7 Sub and Function Procedures.
BIM313 – Advanced Programming Simple Controls 1. Contents Traditional Controls – Labels, Text Boxes, Buttons, Check Boxes, List Boxes, Combo Boxes Advanced.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
CSCI 3327 Visual Basic Chapter 10: Windows Forms GUI: A Deeper Look UTPA – Fall 2011.
Chapter 12: Using Controls. Examining the IDE’s Automatically Generated Code A new Windows Forms project has been started and given the name FormWithALabelAndAButton.
110 M - 1 ListBoxes & ComboBoxes Provide a list for the user to select from Various styles, choose based on –Amount of data to be displayed –Space available.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Seven More on the Repetition Structure.
CIS 338: VB.NET Components Dr. Ralph D. Westfall April, 2011.
ListBox, ComboBox, Menu Chapter 5.4, ComboBox Control: Properties & Methods u Combines TextBox features with a short drop- down list  cboOne.AddItem(string)
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 – Graphical User Interfaces Part 2 Outline.
C # Graphical User Interfaces BIT-7 Saad Liaquat.
Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010.
Controls in C++/CLI (2) CheckBox RadioButton GroupBox ListBox.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 17 – Flag Quiz Application Introducing One-Dimensional.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter Six The Do Loop and List Boxes.
1 Chapter Ten Using Controls. 2 Objectives Learn about Controls How to create a Form containing Labels How to set a Label’s Font How to add Color to a.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Module 1 Window Forms – Basic, Grouping and Graphic controls 1.
Win32 Controls & ActiveX Integration In this presentation… –Introduction to the new Win32 controls. What they are? How they are enabled? Potential uses.
Controls Part 2. DateTimePicker Control Used for representing Date/Time information and take it as input from user. Date information is automatically.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al- ajmi Chapter 3 Some Visual Basic Controls and Events Visual Basic. NET.
AdditionalControls 1. The MenuStrip 2 Double-click Let’s begin to design the menu bar for VB! Let’s begin to design the menu bar for VB! 3.
 A ListBox control displays a list of items and allows the user to select one or more  Drag from Toolbox to create this control on a form.
Iterations (aka Loops). 2 Loops Loops (iterations) are segments of code that may be executed several times. Fixed-count (definite) loops repeat a fixed.
Unit 6 Repetition Processing Instructor: Brent Presley.
Variables and Expressions Programming Right from the Start with Visual Basic.NET 1/e 7.
Java Swing Controls. JButton One of the most commonly used swing component is Push Button or simply button which is created through JButton class of Swing.
Iterations (aka Loops). 2 Loops Loops (iterations) are segments of code (loop body) that may be executed several times. Fixed-count (definite) loops repeat.
Jozef Goetz contribution,  Pearson Education, Inc. All rights reserved.  2002 Prentice Hall. All rights reserved.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 5 Decision Making.
Graphical User Interfaces Part 2 1 Outline TreeViews ListViews Tab Control.
© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 9: Chapter 5: Slide 1 Unit 9 Do Until and For… Next Loops Chapter 5 Lists,
COMPUTER PROGRAMMING I Apply Procedures to Develop List Box and Combo Box Objects.
Graphical User Interface
Microsoft Visual Basic 2008: Reloaded Third Edition
Chapter 9 Programming Based on Events
INF230 Basics in C# Programming
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Computing with C# and the .NET Framework
Using Procedures and Exception Handling
Apply Procedures to Develop Menus, List Box and Combo Box Objects
IS 350 Loops.
Repeating Program Instructions
Programming Based on Events
Microsoft Visual Basic 2005: Reloaded Second Edition
The List Box Control Items can be placed into the list at design time or run time The Sorted property causes items in the list to be sorted automatically.
CIS16 Application Development and Programming using Visual Basic.net
CIS 16 Application Development Programming with Visual Basic
Lecture Set 10 Windows Controls and Forms
Visual C# - GUI and controls - 1
Presentation transcript:

1 Graphical User Interfaces Part 2 Outline ListBoxes and CheckedListBoxes ListBoxes CheckedListBoxes ComboBoxes

2 Introduction Continues study of Graphical User Interface Explores: –ListBox –CheckedListBox –ComboBoxes

3 ListBox es and CheckedListBox es ListBoxe s –Allow users to view and select from items on a list –Static objects – user cannot enter new items in the list Properities –Items returns all objects in list –Property SelectedItem returns current selected item –Property SelectedIndex returns index of selected item –SelectionMode property determines number of items that can be selected –SelectedItems and SelectedIndices –Sorted (default is false)

4 ListBox es and CheckedListBox es Common Event –SelectedIndexChanged (default) Common Method –Property GetSelected returns true if property at given index is selected –Add method adds to Items collection myListBox. Items.Add (“myListItem”) Alternatively can add items visually Examine Items property in the Properties window Click the ellipsis to open String Collection Editor

5 ListBox es and CheckListBox es Alternatively can add items visually 1.Examine Items property in the Properties window 2.Click the ellipsis to open String Collection Editor

6 CheckedListBox es CheckedListBox derives from class ListBox –Extends ListBox by placing check boxes next to items –Can add to, remove from or clear list –Can select multiple items from the list at one time Properties –CurrentValue and NewValue return state of object selected –CheckedItems and CheckedIndices return the objects and indices of selected items respectively

7 ListBox es and CheckedListBox es ListBox Selected Items Checked item CheckedListBox Scroll bars appear if necessary

8 ListBoxTest.cs Program Output

9 // add new item (text from input box) // and clear input box private void addButton_Click ( object sender, System.EventArgs e ) { displayListBox.Items.Add( inputTextBox.Text ); inputTextBox.Clear(); } // remove item if one selected private void removeButton_Click (object sender, System.EventArgs e ) { // remove only if item selected if ( displayListBox.SelectedIndex != -1 ) displayListBox.Items.RemoveAt(displayListBox.SelectedIndex ); } // clear all items private void clearButton_Click ( object sender, System.EventArgs e ) { displayListBox.Items.Clear(); } // exit application private void exitButton_Click ( object sender, System.EventArgs e ) { Application.Exit(); } Add event handler Add method Remove method Clear methodTest if item is selected Exit

10

11 // item about to change, add or remove from displayListBox private void inputCheckedListBox_ItemCheck ( object sender, System.Windows.Forms.ItemCheckEventArgs e ) { // obtain reference of selected item string item = inputCheckedListBox.SelectedItem.ToString(); // if item checked add to listbox, otherwise remove from listbox if ( e.NewValue == CheckState.Checked ) displayListBox.Items.Add( item ); else displayListBox.Items.Remove( item ); } // end method inputCheckedListBox_Click ItemCheck event handler Add ItemRemove Item

12 ComboBox es Combine TextBox and drop-down list –Appears as a text box with a down arrow to its right –By default, user can enter text into the text box Properties: –Items: returns objects in the list –DropDownStyle: determines type of ComboBox Simple – text is editable and list portion is always visible DropDown – text is editable and down arrow (default) DropDownList – text is not editable and down arrow –SelectedItem : returns object selected –SelectedIndex : returns index of selected item –Sorted Event : SelectedIndexChanged (default)

13 ComboBox es Demonstrating a ComboBox.

14 Notes Use ComboBox to save space on a GUI –Disadvantage: unlike with ListBOx, the user cannot see available itesms without scrolling Make lists editable only if the program is designed to accept user-submitted elements. Otherwise, user might enter a custom item and then be unable to use it.