本文介绍了运行时RadioButtons不是独家的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正忙着在运行时创建控件,只是为了好玩。



我用它来删除表单上的用户控件。用户控件具有Label,RadioButton和TextBox。没什么大不了的。



I'm playing around with creating controls at runtime, just for fun.

I used this to drop a usercontrol on a form. The user control has a Label, a RadioButton, and a TextBox. No biggie.

int ControlsOnPanel = 0;
Panel pnl = new Panel();
pnl.Left = 5;
pnl.Top = ControlsOnPage * 21;
pnl.BorderStyle = BorderStyle.None;
pnl.BackColor = Color.AliceBlue;
for (int i = 1; i <= numRadioButtons.Value; i++)
{
    ControlsOnPage += 1;
    ControlsOnPanel += 1;
    EditableRadioButton rb = new EditableRadioButton();
    rb.Margin = new Padding(7);
    rb.RadioButtonText = "Type text here";
    rb.RadioButtonLabel = ControlsOnPage.ToString() + ".";
    rb.Top = (ControlsOnPanel * 21);
    rb.Left = 0;
    rb.Parent = pnl;
    pnl.Controls.Add(rb);
    pnl.Height = rb.Top+21;
}
pnlTarget.Controls.Add(pnl);





它将EditableRadioButtons添加到Panel(pnl)就好了,然后将该面板放入另一个面板中。 br />


但RadioButtons不像RadioButtons那样。我可以点击所有这些,然后点击它们。



我错过了什么?或者是因为RadioButton在UserControl中,因此在该控件中已经是独占的,并且将它与其他人一起放在Panel上会不会有什么区别? :(



and it adds the EditableRadioButtons to the Panel (pnl) just fine, then puts that panel inside another one.

But the RadioButtons don't act like RadioButtons. I can click all of them and they stay clicked.

What did I miss? Or is it because the RadioButton is inside a UserControl and therefore is already exclusive within that control, and dropping it on a Panel with others won't make a bit of difference? :(

推荐答案


这篇关于运行时RadioButtons不是独家的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 00:30