且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在面板中添加单选按钮(左侧和右侧)

更新时间:2023-11-30 16:22:52

该代码有点不寻常.
我会这样:
That code is a bit unusual.
I would do it this way:
int yLoc = 28;
int xLoc = 6;
for (int i = 0; i < dt.Rows.Count; i++)
    {
    RadioButton rdo = new RadioButton();
    rdo.AutoSize = false;
    rdo.Height = 20;
    rdo.Width = 215;
    rdo.Padding = new Padding(-10);

    if (i == 4)
        {
        yLoc = 28;
        xLoc = 235;
        }

    rdo.Location = new Point(xLoc, yLoc);
    yLoc += 25;

    rdo.Font = new System.Drawing.Font(new FontFamily("Mangal"), 9, FontStyle.Bold);
    rdo.Text = dt.Rows[i]["Rolename"].ToString();
    pnlRole.Controls.Add(rdo);
    rdo.CheckedChanged += new EventHandler(radiobuttonchecked);
    }



[edit] Dunno的方式,但<"更改为<<",已修复-OriginalGriff [/edit]



[edit]Dunno how, but "<" changed to "<<", Fixed - OriginalGriff[/edit]