顶部,底部,左侧,右侧的C#标准类(枚举?)

TK.*_*TK. 7 c#

是否有一个标准的c#类定义了一个名义上的左,右,上和下?

我应该使用自己的吗?

enum controlAlignment
{
    left = 1,
    top,
    right,
    bottom,
    none = 0
}
Run Code Online (Sandbox Code Playgroud)

Cer*_*rus 20

快速搜索显示以下Framework Enumerations已经拥有这些成员(其中一些还有其他成员):

  • AnchorStyles - System.Windows.Forms
  • Border3DSide - System.Windows.Forms
  • DockStyle - System.Windows.Forms
  • 边缘 - System.Windows.Forms.VisualStyles
  • TabAlignment - System.Windows.Forms
  • ToolStripStatusLabelBorderSides - System.Windows.Forms
  • VerticalAlignment - System.Windows.Forms.VisualStyles

  • 使用Visual Studio中的"对象浏览器"完成此搜索是没有价值的. (4认同)

Kna*_*bax 10

一个很好的枚举也可能是:

System.Drawing中.ContentAlignment(在System.Drawing.dll中)

这些是其成员:

public enum ContentAlignment
{
    TopLeft = 1,
    TopCenter = 2,
    TopRight = 4,
    MiddleLeft = 16,
    MiddleCenter = 32,
    MiddleRight = 64,
    BottomLeft = 256,
    BottomCenter = 512,
    BottomRight = 1024,
}
Run Code Online (Sandbox Code Playgroud)

  • @Bitterblue 接受的答案使用 System.Windows.Forms.AnchorStyles。这使用 System.Drawing.ContentAlignment。看,我的 wpf 中没有导入任何 winforms 的东西。 (2认同)

Mic*_*ier 7

也许System.Windows.Forms.AnchorStyles或System.Windows.Forms.DockStyles可以完成这项工作.