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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Hemant SrivastavaPosted Oct 6, 2014, 5:07 PM
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
Hemant SrivastavaPosted Oct 6, 2014, 4:54 PM