如何使用CheckedListBox和按钮清除两个RichTextBox。

问题描述 投票:0回答:1

谁能告诉我,我如何使用一个按钮清除RichTextBox中的内容?CheckedListBox - 选择哪个rtb将被清除?

How to clear rtb using button and CheckedListBox

我有一个问题与CheckedListBox - 它的工作为一个选择的位置,但不为检查标记。

c# button richtextbox checkedlistbox
1个回答
1
投票
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();
                    }
                }
            }
© www.soinside.com 2019 - 2024. All rights reserved.