0% found this document useful (0 votes)
163 views

Listbox Checkedlistbox

The document provides code examples for using list boxes and check boxes in a Windows Form application. It demonstrates how to add list boxes and check boxes, populate them with items, handle selection change events, copy and move items between list boxes, and retrieve selected items. Errors that can occur with empty selections are also discussed. String builder is used to concatenate multiple selected items into a single string for display.

Uploaded by

Mohamad Saad
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
163 views

Listbox Checkedlistbox

The document provides code examples for using list boxes and check boxes in a Windows Form application. It demonstrates how to add list boxes and check boxes, populate them with items, handle selection change events, copy and move items between list boxes, and retrieve selected items. Errors that can occur with empty selections are also discussed. String builder is used to concatenate multiple selected items into a single string for display.

Uploaded by

Mohamad Saad
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 41

Electro-Team

Interesting Education

[email protected]

ListBox & CheckedListBox

DialogBox

Display Toolbox

Add 2 Buttons & 1 ListBox

Display Properties Window

Select item property of ListBox

Add items of ListBox

Press ok to precede

Rename Form1 by changing Text property

Change Font property for all controls

Event
Button_Click

Changing Form1.BackColor

Double click Button1

Event
ListBox1_SelectedIndexChanged

Changing Form1.BackColor

Double click ListBox1

Add ListBox2

Change Text Property of Button1

Event
Button_Click

Copy Item from ListBox1 to ListBox2

Event
Button_Click

Moving Item from ListBox1 to ListBox2

Clear all Items

Event
Button_Click

Edit selected Item

Event
Button_Click

Error
ListBox1.Items(ListBox1.SelectedIndex) = TextBox1.Text ListBox1.Items
White Red Black yellow

ListBox1.SelectedIndex
0 1 2 3

No selection made mean ListBox1.SelectedIndex = -1 , this

value will produce an Error.

Copy selected Item to Textbox

Event
ListBox1_SelectedIndexChanged

Replace ListBox by CheckedListBox

Event
Button_Click

Get all items in message box

Code illustration
Dim X As New System.Text.StringBuilder For I = 0 To 3 X.Append(CheckedListBox1.Items(I)) X.Append(" ") Next MessageBox.Show(X.ToString())
System.Text StringBuilder NameSpace Class

Append(item)
ToString

Append (String)
Method

Modify Last Code


Dim X As New System.Text.StringBuilder For Each item In CheckedListBox1.Items X.Append(item) X.Append(" ") items spaces

Next
MessageBox.Show(X.ToString())
System.Text StringBuilder Items Append(item) NameSpace Class Property Append (String)

ToString

Method

Code illustration
NameSpace Class Property Append (String) container for a set of identifiers (names) A set of instance information for a real content. Property Appends a copy of the specified string to this instance. convert the StringBuilder object to a String object before you can pass the string represented by the StringBuilder object to the user interface.

ToString (Method)

You might also like