C# Adding style to a control

前端 未结 2 1428
孤街浪徒
孤街浪徒 2021-01-11 17:21

I have a Panel and I am adding controls inside this panel. But there is a specific control that I would like to float. How would I go about doing that?

pnlOverheadD

2条回答
  •  执笔经年
    2021-01-11 17:34

    If you have a CSS class defined for the control, you could do this before calling the Controls.Add method:

    lnkCalcOverhead.CssClass = "MyClass";
    

    If you want to use the style attribute directly, try this:

    lnkCalcOverhead.Style.Add("float", "left");
    

提交回复
热议问题