By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,334 Members | 1,388 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,334 IT Pros & Developers. It's quick & easy.

Checked Listbox?

P: n/a
Hi, all.

I have a requirement for one of my programs to have a "Checked Listbox" that
contains a list of all my local/remote drives.

I woudl like users to click one or more drives that I need to search for
particular files.

Can anyone tell me how to implement this in .NET 2.0 using VB or C#?

I also need to know how to iterate thru the listbox to determine what items
are selected and extract there value property.

Thank you --

May 18 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
"dm1608" <dm****@spam.net> schrieb:
I have a requirement for one of my programs to have a "Checked Listbox"
that contains a list of all my local/remote drives.


Check out the CheckedListBox control.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

May 18 '06 #2

P: n/a
checked list box control or listview control with checkboxes enabled

"dm1608" <dm****@spam.net> wrote in message
news:On**************@TK2MSFTNGP03.phx.gbl...
Hi, all.

I have a requirement for one of my programs to have a "Checked Listbox"
that contains a list of all my local/remote drives.

I woudl like users to click one or more drives that I need to search for
particular files.

Can anyone tell me how to implement this in .NET 2.0 using VB or C#?

I also need to know how to iterate thru the listbox to determine what
items are selected and extract there value property.

Thank you --

May 18 '06 #3

P: n/a
I'd use a FileOpenDialog rather than a list box, it allows the user to drill
down and select exactly what they want, saving them time.

.... and how could you list "remote drives", if you mean mapped drives that's
one thing, but otherwise how can you know what drives are available -- the
FileOpenDialog would allow the user to select a drive on another machine
which your application wouldn't know about otherwise.

I think you're reinventing the wheel.
I have a requirement for one of my programs to have a "Checked Listbox" that
contains a list of all my local/remote drives.

I woudl like users to click one or more drives that I need to search for
particular files.


May 18 '06 #4

P: n/a
Yeah, but I need them to be able to select multiple drive letters so my
application can scan for the relevent information.

I'm not sure how to use the Checked Listbox control and how to iterate thru
it


"PIEBALD" <PI*****@discussions.microsoft.com> wrote in message
news:26**********************************@microsof t.com...
I'd use a FileOpenDialog rather than a list box, it allows the user to
drill
down and select exactly what they want, saving them time.

... and how could you list "remote drives", if you mean mapped drives
that's
one thing, but otherwise how can you know what drives are available -- the
FileOpenDialog would allow the user to select a drive on another machine
which your application wouldn't know about otherwise.

I think you're reinventing the wheel.
I have a requirement for one of my programs to have a "Checked Listbox"
that
contains a list of all my local/remote drives.

I woudl like users to click one or more drives that I need to search for
particular files.

May 18 '06 #5

P: n/a
Which they can do with a FileOpenDialog, they can even select multiple
individual files.

May 18 '06 #6

P: n/a
> Which they can do with a FileOpenDialog, they can even select multiple
individual files.


OK, I'm wrong again -- you can't use it to select directories :( I wish it
could, seems like some lacking functionality.

But my basic point is still valid, I would use an OpenFileDialog to allow
the user to select exactly which files to use.

And consider this: if your application doesn't want to allow the user to
know what files are in use then I don't know why they should know and select
_where_ they are either.

May 18 '06 #7

P: n/a
How about a FolderBrowserDialog? Although it doesn't seem to allow selection
of multiple directories :(
May 18 '06 #8

P: n/a
Thanks -- but I think I really want them to select drives and not even have
the ability to select folders.

Drives are really all I need. I.E., they want to search C: drive and D:
drive. Then they'd select both. Otherwise, they would select C: only or
whatever.

"PIEBALD" <PI*****@discussions.microsoft.com> wrote in message
news:A9**********************************@microsof t.com...
How about a FolderBrowserDialog? Although it doesn't seem to allow
selection
of multiple directories :(

May 19 '06 #9

P: n/a
In article <eO**************@TK2MSFTNGP03.phx.gbl>, dm****@spam.net
says...
Thanks -- but I think I really want them to select drives and not even have
the ability to select folders.

Drives are really all I need. I.E., they want to search C: drive and D:
drive. Then they'd select both. Otherwise, they would select C: only or
whatever.

...


Checkout the DriveInfo class (new in .NET 2.0).

--
Larry Steeger
RusSte, Inc. - http://www.russte.com
May 19 '06 #10

P: n/a

It fairly straight forward. To load the box you add to the Items list and
include it the item is checked by default or not. The code looks like
this

clbVendorShows.Items.Add("E:", False)

You will need to get a list of all the drives in the system and customize
the statement with what you want it to list. You will have one of theses
statements for each item in the checkedlistbox.

Note: If you want to reselect an item, the use;
clbVendorShows.Items.Add("C:", True)

To read back you use
isChecked = clbVendorShows.GetItemChecked(i)
where i is the index into the items.

Here's some code I just used to step through all the items in the box to
see if they where checked.
For i = 0 To clbVendorShows.Items.Count - 1
isChecked = clbVendorShows.GetItemChecked(i)
' do some other things here based on what I found ...
Next

There are other ways to reach what is checked, in my case I needed to
know what was check and what wasn't. Read up on the documentation in VS,
on the collections available. There is one for "checked" items that will
return all the items that were checked. That would be handy for when you
just care about what was selected and not what wasn't selected.

Bernie
"dm1608" <dm****@spam.net> wrote in
news:OM**************@TK2MSFTNGP05.phx.gbl:

I'm not sure how to use the Checked Listbox control and how to iterate
thru it


May 21 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.