Home All Groups Group Topic Archive Search About
Author
18 May 2006 1:34 PM
dm1608
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 --

Author
18 May 2006 2:04 PM
Herfried K. Wagner [MVP]
"dm1608" <dm1608@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/>
Author
18 May 2006 2:22 PM
Smokey Grindle
checked list box control or listview control with checkboxes enabled

Show quoteHide quote
"dm1608" <dm1608@spam.net> wrote in message
news:OnuAI$neGHA.3572@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 --
>
>
>
Author
18 May 2006 3:07 PM
PIEBALD
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.

Show quoteHide quote
> 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.
Author
18 May 2006 4:26 PM
dm1608
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




Show quoteHide quote
"PIEBALD" <PIEB***@discussions.microsoft.com> wrote in message
news:2694E3E5-0857-4C12-8192-BA01957203A2@microsoft.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.
>
Author
18 May 2006 4:41 PM
PIEBALD
Which they can do with a FileOpenDialog, they can even select multiple
individual files.
Author
18 May 2006 5:04 PM
PIEBALD
> 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.
Author
18 May 2006 5:17 PM
PIEBALD
How about a FolderBrowserDialog? Although it doesn't seem to allow selection
of multiple directories  :(
Author
19 May 2006 5:22 AM
dm1608
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.



Show quoteHide quote
"PIEBALD" <PIEB***@discussions.microsoft.com> wrote in message
news:A9661C38-A6FA-4BE7-A153-6BE6260B7542@microsoft.com...
> How about a FolderBrowserDialog? Although it doesn't seem to allow
> selection
> of multiple directories  :(
>
>
Author
19 May 2006 7:21 PM
Lawrence R. Steeger
In article <eOjYzQweGHA.1***@TK2MSFTNGP03.phx.gbl>, dm1608@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
Author
20 May 2006 7:48 PM
Bernie Hunt
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


Show quoteHide quote
"dm1608" <dm1608@spam.net> wrote in
news:OMLFlfpeGHA.4912@TK2MSFTNGP05.phx.gbl:


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