【问题标题】:Displaying corresponding text relating to check box names in Word 2010 and visual Studio 2010 that is removed when box is unchecked?在 Word 2010 和 Visual Studio 2010 中显示与复选框名称相关的相应文本,在取消选中框时将其删除?
【发布时间】:2013-01-17 16:06:30
【问题描述】:

我当前在 Visual Studio 中用于在单击复选框时填充文本字段的代码是:

    private void checkBox1_CheckedChanged(object sender, EventArgs e)
    {
        this.displayText.Text += "Internal Use";
    }

    private void checkBox2_CheckedChanged(object sender, EventArgs e)
    {
        this.displayText.Text += "Company Confidential";
    }

    private void checkBox3_CheckedChanged(object sender, EventArgs e)
    {
        this.displayText.Text += "Customer Confidential";
    }

    private void checkBox4_CheckedChanged(object sender, EventArgs e)
    {
        this.displayText.Text += "Strictly Confidential";
    }

这很好,但我希望在未选中这些框时删除文本。是否有人对我可能需要使此要求起作用的特定代码有任何见解?

非常感谢。

【问题讨论】:

    标签: c# visual-studio-2010 templates ms-word


    【解决方案1】:

    你的意思是像

    private void checkBox1_CheckedChanged(object sender, EventArgs e)
    {
        if (checkBox1.Checked)
            this.displayText.Text = "Internal Use";
        else
            this.displayText.Text = String.Empty;
    }
    

    你确定这不是你说的 C#?

    【讨论】:

    • 这绝对是完美的谢谢。抱歉,我说的是 c#,对我来说是一个非常新的概念,我有点糊涂了。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-19
    • 1970-01-01
    相关资源
    最近更新 更多