473,387 Members | 1,497 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,387 software developers and data experts.

Checked Listbox?

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
10 3783
"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
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
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
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
Which they can do with a FileOpenDialog, they can even select multiple
individual files.

May 18 '06 #6
> 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
How about a FolderBrowserDialog? Although it doesn't seem to allow selection
of multiple directories :(
May 18 '06 #8
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
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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Hrvoje Voda | last post by:
After I fill checked listbox with data, I would like to checked all items in list ? Hrcko
1
by: Hrvoje Voda | last post by:
I fill a checked listBox with data from dataset. I would like, when a user checked one item , to save it in dataset. The problem is that I don't know how to get its ID number, because I have...
3
by: Hrvoje Voda | last post by:
I fill a checked listbox with name from dataset. I would like to go through that names and if I find the same name in list, then that line should be checked. How? Hrcko
3
by: touf | last post by:
Hi, I've a Tabcontrol with many tabpages, in each one I've a checked listBox. The problem is that when I check items in listBox and go to an other page I lost the check (when i return to my...
3
by: Dean Slindee | last post by:
In a checked listbox, I am allowing drag/drop of the items within (resequencing). Problem is, when dropping a checked item, the checked state always reverts to unchecked (unwanted). Anyone know...
2
by: alex | last post by:
Hi, is there a way to a) dissable a particular item in the checked listbox. i.e. I dont want users to change its state b) to change the font color/property of one item in the checked list box....
2
by: Nathan | last post by:
How do you set an checked listbox item to be checked using code? Can't seem to find a method for doing that.
1
by: Dennis | last post by:
I have a checked list box and am trying to use the SetItemCheck method as follows: mylistbox.SetItemChecked(indextoset, True) It seems to have no effect and the display does not show the box...
10
by: dm1608 | last post by:
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...
2
by: Tim.Geiges | last post by:
This seems like ti should be very simple but I am sort of a newb and this one is killing me I am just trying to copy all the items that are checked in listView2 over to listView1 when a button is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.