473,486 Members | 2,181 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem trying to select all items in listbox

I have used the following code, but I get an error. 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=SelectionMode.MultipleSimpl e;
// Loop through all items the ListBox (lstTeams).
for (int x = 0; x < lstTeams.Items.Count; x++)
{
lstTeams.SelectedIndex = x;
}
}
The error is: The type or namespace name 'SelectionMode' could not be found
(are you missing a using directive or an assembly reference?)

Is there a using System.? that I need to include to get Listbox property to
display?
--
DCount
Nov 22 '05 #1
1 2441
> The error is: The type or namespace name 'SelectionMode' could not be found
(are you missing a using directive or an assembly reference?)

Is there a using System.? that I need to include to get Listbox property to
display?


msdn is your friend:

http://msdn.microsoft.com/library/de...classtopic.asp

-> using System.Windows.Forms;
also i think you should use

SetSelected(x,true);

instead of

SelectedIndex = x;
Nov 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
395
by: DCount17 | last post by:
I have used the following code, but I get an error. 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...
0
1318
by: L.Peter | last post by:
Dear Group, I am doing Drag and Drop function and see this problem if I select 3 from listBox1 and drag to listBox2, the value in listBox1 is not updated, even I move (or use up and down keyboard)...
1
2505
by: Joe Bloggs | last post by:
I am trying display the contents of a table in a web page, select certain rows from that table and then display the fields that I have selected (now table columns) as text in a Label object....
2
5727
by: Matt Sawyer | last post by:
Hi, I'm attempting to do a drag and drop operation from one listbox to another. I have my listboxes setup with SelectionMode = MultiExtended so that I can use the shift key, cntrl key, etc. to...
3
3037
by: Lloyd Sheen | last post by:
I have a page that works fine. I am trying to optimize the page by overriding some of the Information that is being saved in the hidden VIEWSTATE. If I make the properties of the dropdown False...
9
2132
by: Matt Tapia | last post by:
I having a problem that receives the following error: Specified cast is not valid And I need some help. Here is what is happening: I have a form with a drop-down control that contains a list...
2
3814
by: tangokilo | last post by:
Hello and thanks for your help, I have the following Listbox created in VisualStudio 2003 designer, desiring to select multiple entries from that list: -------------------------------...
10
6343
by: ads | last post by:
hi, after binding the dropdownlist to a datasource, ive experience this error "Cannot have multiple items selected in a dropdownlist" after using the code:...
4
1597
by: camainc | last post by:
I am adding some objects to a standard list box. When I add multiple objects, I experience no problems. However, when I add a single object, I cannot set the SelectedIndex property to 0 - it stays...
1
4008
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6842
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7330
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5434
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4865
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.