473,395 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 2436
> 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
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
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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
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,...

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.