HI
I need to save and return certain values from check box list in c#
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Hemant SrivastavaRank #581 · 4.2K reputationPosted Oct 6, 2014, 12:54 PM EDT
Hemant SrivastavaRank #581 · 4.2K reputationPosted Oct 6, 2014, 1:07 PM EDT
Here is a sample code for your help
In this I created a Form named 'MyChildForm' that has CheckBoxListControl where user could select the multiple items on CheckBoxList
OnClicking 'OK' button, form gets closed and all the checked items are saved into a property named 'ListOfCheckedItems'
public partial class MyChildForm : Form _listOfCheckedItems;
{
private List
public List ListOfCheckedItems
{
get { return _listOfCheckedItems; }
set { _listOfCheckedItems = value; }
}
public MyChildForm()
{
InitializeComponent();
}
private void Oct_2014_Load(object sender, EventArgs e)();
{
_listOfCheckedItems = new List
}
// Ok Button
private void button1_Click(object sender, EventArgs e)
{
//One by one it will fetch the items from the checked Items of the Checkedlistbox.
foreach (var item in checkedListBox1.CheckedItems)
{
//Add the retrieved item into the our List.
_listOfCheckedItems.Add(item.ToString());
}
this.Close();
}
}
On some other form, I call the ChildForm and retrieves all the checked values into a List (list)
MyChildForm oMyChildForm = new MyChildForm(); list = oMyChildForm.ListOfCheckedItems;
oMyChildForm.ShowDialog();
List
Hop it might help you to solve your problem