Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Read an Arraylist and print the values with a checkbox

Posted on 2009-02-13
3
Medium Priority
?
840 Views
Last Modified: 2012-05-06
I want to loop through an arraylist and show each value on the form with a checkbox in front of the value.

eg :- Arraylist contains

"item1","item2","item3"

on the form i want it as

'checkbox' item1
'checkbox' item2
'checkbox' item3
0
Comment
Question by:pratikshahse
3 Comments
 
LVL 27

Expert Comment

by:nmarun
ID: 23639668
So you want to add checkbox controls dynamically for each entry in an array list?
0
 
LVL 5

Accepted Solution

by:
Imperdonato earned 2000 total points
ID: 23639699
Add a CheckBoxList on your form.
Assuming id of the checklist box just added is cbList.
Assuming itemsArrayList is the arraylist.

In your code behind, write this code:



foreach (string str in itemsArrayList)
{
    ListItem item = new ListItem(str, str);
    cbList.Items.Add(item);
}

Open in new window

0
 
LVL 1

Expert Comment

by:corpuslabs
ID: 23639707

For each Str as String in ArrayList
    CheckBoxList.Items.Add(Str)
Next

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question