c#控件的可见属性在事件上没有变化

发布于 2025-02-11 07:20:08 字数 427 浏览 1 评论 0原文

我有一个带有combobox的winform,带有选项是或否,这是我的事件代码:

    private void cmbYesNo_SelectedIndexChanged(object sender, EventArgs e)
    {
        ComboBox cmb = sender as ComboBox;
        if (cmb.Text == "Yes")
        {
            this.button1.Visible = true;
        }
        else
        {
            this.button1.Visible = false;
        }
    }

调试代码,它确实正确地进入了我想设置可见属性的正确语句,但它不会物理上对其进行更改形式。我想念什么?

I have a Winform with a combobox with the options Yes or No and this is my event code:

    private void cmbYesNo_SelectedIndexChanged(object sender, EventArgs e)
    {
        ComboBox cmb = sender as ComboBox;
        if (cmb.Text == "Yes")
        {
            this.button1.Visible = true;
        }
        else
        {
            this.button1.Visible = false;
        }
    }

Debugging the code, it does correctly go into the correct statement where I am wanting to set the visible property but it doesn't physically change it on the form. What am I missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文