ListBox Checkbox

In .Net 1.1 I used a listbox added checkboxes and use the following to check if something was checked:
 
if (LstFields.CheckedItems.Count > 0)

I tried using the same in  .Net 2.0 the .CheckedItems property does not exist.  Does anybody know the new syntax?

Thanks.

yanci1179Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carl TawnSystems and Integration DeveloperCommented:
Are you using a standard ListBox or a CheckedListBox ?
0
yanci1179Author Commented:
in 1.1 I used a standart ListBox and then I just added the checkboxes.   There is a property called 'CheckBoxes' and I set it to true.  The property is not available in 2.0.  Was it removed?  I guess I can look at CheckedListBox
0
Carl TawnSystems and Integration DeveloperCommented:
I assume that CheckedListbox is the replacement for a Listbox with the checkboxes option.

I tried a CheckedListBox in 2.0 and the CheckedItems member is there.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

yanci1179Author Commented:
thanks, I am just going to go ahead and use the CheckedListBox (I don't really have a choice).

In 1.1. I used

foreach (ListViewItem li in LstFields.CheckedItems)

Do you know what the equivalent of ListViewItem is for the CheckedListBox

0
Carl TawnSystems and Integration DeveloperCommented:
Well according to the documentation, CheckedListBox derives from ListBox so I would guess its the same as with the ListBox.
0
yanci1179Author Commented:
no, I'm getting an error when I use ListViewItem
0
yanci1179Author Commented:
In 1.1 I had a dynamic ListBox which would populate base on the users selection.  Then I used the text of the checkbox to create dynamic labels and textboxes:

I worked fine, but it does not work in 2.0


foreach (ListViewItem li in ChkLstFields.CheckedItems)
 {
       ct += 1;

       if (li.Text == "Method")
       {
          //create label based on the text
         //create combobox based on the text
        }
        else if (li.Text == "Neigh")
        {
            //create label based on the text
         //create combobox based on the text
         }
}
   
0
Carl TawnSystems and Integration DeveloperCommented:
This seems to work, its a little odd that it appears to have gone from ListViewItem to string, but there we go:

            foreach (string c in checkedListBox1.CheckedItems)
            {
                MessageBox.Show(c);
            }
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
yanci1179Author Commented:
It Worked!!!!  Thanks so much!!!!!!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.