如何删除 c#.net 中 statusStrip 的两项之间的间隙(与 2005 相比)

发布于 2024-09-03 19:17:38 字数 228 浏览 1 评论 0原文

我在statusStrip中有4个连续的ToolStripStatusLabel,它们之间有一个空格,要求是我们在statusStrip中的这4个ToolStripStatusLabel之间不需要任何空格。

请告诉我如何删除它们之间的空间。我有一种替代方法可以在一个 statusStrip 中设置所有值,但由于所有值都来自不同的来源,因此这是一个重大变化。所以请为我提供解决方案(我正在使用 c#.net - vs2005)

I have 4 continus ToolStripStatusLabel in statusStrip and their is a space between them, the requirement is like that we dont need any space between these 4 ToolStripStatusLabel in statusStrip.

Please tell me how can we remove space between them.. i have got an alternative to set all values in one statusStrip but as all values are coming from various sources so its a major change. so please provide me solution ( i am using c#.net - vs2005)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我偏爱纯白色 2024-09-10 19:17:38

您可以更改 ToolStripStatusLabels 的边距属性,甚至可以更改为负数:
例如,尝试 '-2; 3; -2; 2',这将使项目更加靠近。
注意不要靠得太近,避免重叠。

为了澄清我的意思是什么属性,一些示例代码(设计者生成的):

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        this.statusStrip1 = new System.Windows.Forms.StatusStrip();
        this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
        this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel();
        this.statusStrip1.SuspendLayout();
        this.SuspendLayout();
        // 
        // statusStrip1
        // 
        this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
        this.toolStripStatusLabel1,
        this.toolStripStatusLabel2});
        this.statusStrip1.Location = new System.Drawing.Point(0, 240);
        this.statusStrip1.Name = "statusStrip1";
        this.statusStrip1.Size = new System.Drawing.Size(284, 22);
        this.statusStrip1.TabIndex = 0;
        this.statusStrip1.Text = "statusStrip1";
        // 
        // toolStripStatusLabel1
        // 
        this.toolStripStatusLabel1.Margin = new System.Windows.Forms.Padding(-3, 3, -3, 2);
        this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
        this.toolStripStatusLabel1.Size = new System.Drawing.Size(25, 17);
        this.toolStripStatusLabel1.Text = "123";
        // 
        // toolStripStatusLabel2
        // 
        this.toolStripStatusLabel2.Margin = new System.Windows.Forms.Padding(-3, 3, -3, 2);
        this.toolStripStatusLabel2.Name = "toolStripStatusLabel2";
        this.toolStripStatusLabel2.Size = new System.Drawing.Size(25, 17);
        this.toolStripStatusLabel2.Text = "234";
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(284, 262);
        this.Controls.Add(this.statusStrip1);
        this.Name = "Form1";
        this.Text = "Form1";
        this.statusStrip1.ResumeLayout(false);
        this.statusStrip1.PerformLayout();
        this.ResumeLayout(false);
        this.PerformLayout();

    }

You can change the margin-property of the ToolStripStatusLabels, even to negative numbers:
For example, try '-2; 3; -2; 2', this will make the items get closer together.
Watch out not to go too close, to avoid overlapping.

To clarify, what property I mean, some sample code (designer generated):

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        this.statusStrip1 = new System.Windows.Forms.StatusStrip();
        this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
        this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel();
        this.statusStrip1.SuspendLayout();
        this.SuspendLayout();
        // 
        // statusStrip1
        // 
        this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
        this.toolStripStatusLabel1,
        this.toolStripStatusLabel2});
        this.statusStrip1.Location = new System.Drawing.Point(0, 240);
        this.statusStrip1.Name = "statusStrip1";
        this.statusStrip1.Size = new System.Drawing.Size(284, 22);
        this.statusStrip1.TabIndex = 0;
        this.statusStrip1.Text = "statusStrip1";
        // 
        // toolStripStatusLabel1
        // 
        this.toolStripStatusLabel1.Margin = new System.Windows.Forms.Padding(-3, 3, -3, 2);
        this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
        this.toolStripStatusLabel1.Size = new System.Drawing.Size(25, 17);
        this.toolStripStatusLabel1.Text = "123";
        // 
        // toolStripStatusLabel2
        // 
        this.toolStripStatusLabel2.Margin = new System.Windows.Forms.Padding(-3, 3, -3, 2);
        this.toolStripStatusLabel2.Name = "toolStripStatusLabel2";
        this.toolStripStatusLabel2.Size = new System.Drawing.Size(25, 17);
        this.toolStripStatusLabel2.Text = "234";
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(284, 262);
        this.Controls.Add(this.statusStrip1);
        this.Name = "Form1";
        this.Text = "Form1";
        this.statusStrip1.ResumeLayout(false);
        this.statusStrip1.PerformLayout();
        this.ResumeLayout(false);
        this.PerformLayout();

    }
伴我心暖 2024-09-10 19:17:38

尝试将 ToolStripStatusLabels 的左右边距设置为负值。您只需要进行一些实验,看看什么确切值可以为您提供您正在寻找的位置。

Try to set the left and right Margin of your ToolStripStatusLabels to a negative value. You'll just have to experiment a bit to see what exact value gives you the position you are looking for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文