如何在StatusStrip中右对齐控件?

Eri*_*ver 92 c# statusstrip winforms

我试图右对齐一个控件StatusStrip.我怎样才能做到这一点?

我没有看到一个属性来设置ToolStripItem控件,指定它们在父项上的物理对齐方式StatusStrip.

如何让消息下拉到右对齐?http://i.friendfeed.com/ed90b205f64099687db30553daa79d075f280b90

Eri*_*ver 219

发布后几乎立即通过MSDN论坛找到它:)

您可以使用ToolStripLabel到伪右侧被设置对齐控件Text属性string.Empty和设置Spring属性true.这将使其填充所有可用空间并将所有控件推到右侧ToolStripLabel.

  • 如果`StatusStrip.LayoutStyle == ToolStripLayoutStyle.Table`(这是默认值),这将仅**** (26认同)
  • 尼斯.两侧都带有Spring的StatusStripLabel似乎使控件居中 (12认同)
  • _我想知道Alignment属性的作用_我看不到任何此类属性。 (2认同)

VBo*_*Cat 6

对我来说,它采取了两个简单的步骤:

  1. 设置MyRightIntendedToolStripItem.AlignmentRight
  2. 设置MyStatusStrip.LayoutStyleHorizontalStackWithOverflow


Mar*_*man 5

作为补充说明,这是因为在Win32 API中,单元格是固定宽度或填充剩余空间-1

int statwidths[] = {100, -1};

SendMessage(hStatus, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM)statwidths);
SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Hi there :)");
Run Code Online (Sandbox Code Playgroud)

如果内存正确地为我服务,则每个状态栏只能有一个填充单元格(-1).

您还可以添加第三个中间单元格,并为其指定fill属性以获得更加一致的StatusBar.一致,因为消息的左侧插入了您期望的位置.有点像在StatusNars的MSDN页面上找到的mspaint镜头

我喜欢创意:D