12/14/2019

How To Display Selected CheckedListBox Items In TextBox Separated By Comma In C#

how to display selected checkedlistbox items in textbox separated by comma in c#
how to display selected checkedlistbox items in textbox separated by comma in c#


private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string values = "";
            foreach (object item in checkedListBox1.CheckedItems)
            {
                if (values == "")
                    values = item.ToString();
                else values += "," + item.ToString();

            }
            textBox1.Text = values;
        }