PC Review


Reply
Thread Tools Rate Thread

How can I select ALL items in the listbox at runtime

 
 
=?Utf-8?B?RENvdW50MTc=?=
Guest
Posts: n/a
 
      2nd May 2005
I have used the following code, but I can't find how to get the SetSelection
property to select the items in the listbox (lstTeams). I'm using C#. When
the checkbox is selected, I want to select all items in lstTeams (90 items)
so the user doesn't have to manually select each item:

private void chkAllTeams_CheckedChanged(object sender, System.EventArgs e)
{
//If the user selects "Select All Teams" checkbox, highlight (select all
items).
lstTeams.SelectionMode=ListSelectionMode.Multiple;
// Loop through all items the ListBox (lstTeams).
for (int x = 0; x < lstTeams.Items.Count; x++)
{
lstTeams.SelectedIndex = x;
}
}
It only select the last item.

--
DCount
 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      2nd May 2005

>I have used the following code, but I can't find how to get the SetSelection
>property to select the items in the listbox (lstTeams). I'm using C#.


I assume you mean the SetSelected method.

lstTeams.SetSelected(x, true);



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot select items in listbox send2hamilton@yahoo.com Microsoft Excel Programming 0 25th Mar 2008 03:49 PM
How to color listbox items at runtime? Me Microsoft C# .NET 2 12th Sep 2007 03:58 AM
How do I add items to listbox during runtime? =?Utf-8?B?bWJiY2JhbGxlcjIy?= Microsoft Access Forms 1 1st Aug 2006 10:25 PM
Select *all* items in listbox RD Microsoft Access VBA Modules 5 8th Sep 2005 04:00 PM
How to select all items in the listbox =?Utf-8?B?R2FicmllbA==?= Microsoft Access 2 8th Nov 2004 03:49 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:22 AM.