سؤال

can anybody say me, how can I clear content inside RichTextBox using one button where: CheckedListBox - select which of rtb will be cleared?

How to clear rtb using button and CheckedListBox

I have problem with CheckedListBox - It works for one select position, but not for checked/marked.

هل كانت مفيدة؟

المحلول

private void button1_Click(object sender, EventArgs e)
        {

            for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                if (checkedListBox1.GetItemChecked(i))
                {
                    string str = (string)checkedListBox1.Items[i];
                    if(str ==  "rtb1")
                    {
                      richTextBox1.Clear();
                      richTextBox1.Focus();
                    }
                     if(str ==  "rtb2")
                    {
                       richTextBox2.Clear();
                       richTextBox2.Focus();
                    }
                }
            }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top