Hi @Roberto Carlos Espinosa , Welcome to Microsoft Q&A,
You can use foreach to iterate through all items in the checklistbox to get them.
You can also traverse the checked items to get the checked items.
Then you can save them where you want:
Here's an example of mine:
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace _9_21_x
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//access all items
List<string> values = new List<string>();
foreach (var item in checkedListBox1.Items)
{
values.Add(item.ToString());
}
Console.WriteLine("All items:");
foreach (var item in values)
{
Console.WriteLine(item);
}
//access all checked items
List<string> checkedValues = new List<string>();
foreach (var item in checkedListBox1.CheckedItems)
{
checkedValues.Add(item.ToString());
}
Console.WriteLine("All checked items:");
foreach (var item in checkedValues)
{
Console.WriteLine(item);
}
}
}
}
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.