读书人

关于Winform自定义控件new Point后没有

发布时间: 2013-02-25 10:23:36 作者: rapoo

关于Winform自定义控件new Point后没显示
本帖最后由 caozhy 于 2013-02-23 14:21:33 编辑 实现RadioButtonList自定义WinForm控件后调试数据都正常了,在最后

void DrawControl()
{
panel1.Controls.Clear();

int count = _mappings.Length;
//Draw and set control
int height = 0;
int x_aris = 50;
int y_aris = 50;
for (int i = 0; i < count; i++)
{
//create the radio button
RadioButton radio = new RadioButton();
radio.Name = i.ToString();
radio.Text = _mappings[i].Text;
radio.AutoSize = true;

//put radio button into the panel
panel1.Controls.Add(radio);
radio.Location = new Point(x_aris, y_aris + height);
height += radio.Height;

//Add click event to radio button
radio.Click += new EventHandler(radio_Click);
}


}

但是在Form端没有显示,我在Form_Load里或者按钮上都没用。 自定义WinForm控件 radiobutton
[解决办法]
在循环结束的时候看radio的位置、大小、Visible是否都正确。

读书人网 >C#

热点推荐