我正在使用 .NET 6.0 和 VS2022 IDE。如何將 2 toolStripStatusLabel1 放置在狀態條控制元件的兩個角。我無法進行任何分組。所以如果可能的話,請分享一些建議。
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
this.toolStripStatusLabel1.Size = new System.Drawing.Size(151, 20);
this.toolStripStatusLabel1.Text = "SUM Count Average";
//
// toolStripStatusLabel2
//
this.toolStripStatusLabel2.Name = "toolStripStatusLabel2";
this.toolStripStatusLabel2.Padding = new System.Windows.Forms.Padding(1000, 0, 0, 0);
this.toolStripStatusLabel2.Size = new System.Drawing.Size(1151, 20);
this.toolStripStatusLabel2.Text = "Elaped Time";
uj5u.com熱心網友回復:
您可以使用或以下解決方案為StatusStrip的專案設定不同的對齊方式:
- 設定
LayoutStyle為HorizontalStackWithOverflow - 或使用
Spring標簽的屬性來控制流量。 - 或改用 ToolStrip。
選項 1:將 LayoutStyle 設定為 Horizo??ntalStackWithOverflow
當LayoutStyle為 Table時,設定 StatusStrip 專案的對齊方式不起作用。這是因為它必須支持Spring屬性的自定義邏輯。要解決問題:
將StatusStrip的LayoutStyleHorizontalStackWithOverflow屬性設定為,然后將所需 ToolStripStatusLabel的AlignmentRight設定為in 代碼(因為 Alignment 屬性ToolStripStatusLabel在設計時是隱藏的)。
注意:請記住,通過更改布局樣式,設定Sprint不再起作用。
選項 2:使用Spring標簽的屬性來控制流量
您可以使用 3 個ToolStripStatusLabel專案;然后對于中間的,將 設定Text為空并將 設定Spring為 true 以填充空間。然后,在此之前的專案之前的專案將左對齊,之后的專案將右對齊。
選項 3:改用 ToolStrip
而不是 StatusStrip,使用 ToolStrip 并添加 2 ToolStripLabel,對于第二個,將 Alignment 設定為Right。
注意:主要的用戶體驗差異是缺少尺寸握把。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/465201.html
