Winform自定义控件new Point后没显示
实现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里或者按钮上都没用。
在循环结束的时候看radio的位置、大小、Visible是否都正确。