我试着理解窗口表单中的组框是如何工作的。我现在的问题。我有两个组盒,每个都有两个无线电按钮。例如,我希望当groupbox1的无线电按钮2被点击时,整个groupbox2是不可见的,或者更好地在其上放置一个白色阴影,而不允许用户使用它。我在这里读过书,但没有找到http://msdn.microsoft.com/en-us/library/system.windows.forms.groupbox.aspx的东西。我尝试了属性可视,但使整个窗口不可见。这是我的示例代码。提前感谢
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace groupbox
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
radioButton1.Checked = true;
radioButton3.Checked = true;
}
private void groupBox1_Enter(object sender, EventArgs e)
{
if (radioButton4.Checked == true) {
this.Visible = false;
}
}
private void groupBox2_Enter(object sender, EventArgs e)
{
if (radioButton2.Checked == true)
{
this.Visible = false;
}
}
}
}
我也读过这个Can you make a groupbox invisible but have it's contents visible?,但是有没有没有面板?
发布于 2013-02-08 08:26:52
试试这个:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
radioButton1.Checked = true;
radioButton3.Checked = true;
radioButton2.CheckedChanged += radioButton2_CheckedChanged;
}
void radioButton2_CheckedChanged(object sender, EventArgs e)
{
groupBox2.Enabled = !radioButton2.Checked;
}
}
发布于 2013-02-08 08:24:39
this
指的是代码所在的类--在本例中是表单。
你应该试试groupBox1.Visible = false;
或groupBox1.Enabled = false;
https://stackoverflow.com/questions/14768404
复制相似问题