本文介绍了C#添加样式控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小组,我添加此面板的内部控制。但是,我想飘起了特定的控制。我会如何做呢?

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?

pnlOverheadDetails是面板的名字

pnlOverheadDetails is the panel name

pnlOverheadDetails.Controls.Add(lnkCalcOverhead);

命名lnkCalcOverhead控制是我想飘起了控制。

The control named lnkCalcOverhead is the control I'd like to float.

在此先感谢

编辑:通过浮动我是CSS样式没有任何幻想:)

By float I meant the css style not anything fancy :)

推荐答案

如果您有控制定义的CSS类,你可以在 Controls.Add被方法:

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

lnkCalcOverhead.CssClass = "MyClass";

如果您想直接使用style属性,试试这个:

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

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

这篇关于C#添加样式控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 18:35