How do I reclaim the space from the "Grip"
Asked Answered
A

5

19

I've got a StatusStrip with a single ToolStripStatusLabel, Spring=true and a background color for notifications.

The problem is that there's an ugly gray square on the right side of the status strip. After fiddling for a while, I realized this is the sizing grip (I had is set to SizingGrip=false, GripStyle=Hidden). Yet even with it hidden, it still hogs the space. I can't get any content on the status strip to extend all the way to the right.

How would you work around this? Note I can't just set the backcolor of the StatusStrip because the Status Label changes colors and has some fading effects.

Akvavit answered 15/4, 2010 at 15:20 Comment(0)
H
29

The StatusStrip.Padding property is borked, it returns the wrong value for Padding.Right if the sizing grip is disabled. You can fix it in your form constructor, like this:

public Form1() {
  InitializeComponent();
  statusStrip1.Padding = new Padding(statusStrip1.Padding.Left,
    statusStrip1.Padding.Top, statusStrip1.Padding.Left, statusStrip1.Padding.Bottom);
}

Using the Left property to specify Right is the fix. Don't bother submitting this bug to Connect, they won't fix it.

Heber answered 15/4, 2010 at 17:16 Comment(0)
N
1

Have a look at this blog entry on MSDN. The question was about changing the size of the sizing grip manually, and I think using the ToolStrip Renderer as suggested could work for you also.

The problem I have so far, is that it removes the background color on a status label in the StatusStrip, so it's not a solution yet, but it's a start.

    public MyForm()
    {
        InitializeComponent();
        statusStrip1.Renderer = new MyRenderer();
    }

    private class MyRenderer : ToolStripProfessionalRenderer
    {
        protected override void OnRenderStatusStripSizingGrip(ToolStripRenderEventArgs e)
        {
            // don't draw at all
        }
    }
Nichollenicholls answered 15/4, 2010 at 15:38 Comment(0)
O
0

I had following problem: when I set tsslSeparator.Spring = true, my right label disappeared immediately after tsslSeparator lost focus. The issue appeared when sizing grip was enabled. When it was disabled, everything worked just fine. The solution was to set right margin for right label to something different than 0.

tsslLogging.Margin = new Padding(0, 3, 2, 2); // this is necessary for right alignment of status bar label

Hope this helps somebody.

Occur answered 2/7, 2014 at 16:34 Comment(0)
S
0

If Microsoft isn't interesting in fixing it, it seems like a proper fix should handle all orientations, and ideally fix all Status Strips (see my answer to Get All Children for definition of GetAllChildren)

    public static StatusStrip FixPadding(this StatusStrip ss) {
        if (!ss.SizingGrip) {
            var fixpad = ss.Padding;

            if (ss.Orientation == Orientation.Horizontal) {
                if (ss.RightToLeft == RightToLeft.No)
                    fixpad.Right = fixpad.Left;
                else
                    fixpad.Left = fixpad.Right;
            }
            else
                fixpad.Bottom = fixpad.Top;

            ss.Padding = fixpad;
        }

        return ss;
    }

    public static void FixStatusStripPadding(this Form f) {
        foreach (var ss in f.GetAllChildren().OfType<StatusStrip>())
            ss.FixPadding();
    }
Sackbut answered 17/12, 2016 at 0:44 Comment(0)
I
0

I tried this:

ssStatus.Padding = Padding.Empty

It works for me.

Indicate answered 16/11, 2023 at 5:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.