Hide the Resize arrow in the form C# - c#

In my C# application I have set the form border to Fixed3D, as I don't want to re-size it. However, the arrow on the bottom right of the form still appears for re-size even though it doesn't allow re-sizing.
How do I hide that arrow?

My best guess is you have a StatusStrip on the form. If so, set the SizingGrip property to false.

What you are looking for is:
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
or it can be set in form designer property window.
Correction:
On the form, setting the Border to Fixed3D will remove the sizing grip from the form... UNLESS you have a status strip on the form with a SizingGrip set to true.
Solution: insure that your form's statusStrip1.SizingGrip = false;

See: http://msdn.microsoft.com/en-us/library/system.windows.forms.form.sizegripstyle.aspx

there should be a property of the form called ShowSizeGrip, just set it to False.

Related

Skip Aero Window Animation

How can I disable the "opening" animation of a window under Aero programatically?
When opening a new Form it "pops in" (fade in + a slight scaling transformation).
I want to stop this animation and show the window instantly.
I already tried to set the Location property of the Form to somewhere offscreen, then calling Show(), and then moving it at its correct location.
But that doesn't help, the animation will continue.
Maybe there is some hidden property I can set?
I don't want to disable open/close/minimize/maximize animations globally!
I just want to skip the "window-open" animation of my window.
I already played around with single and multiple calls ShowWindow(...) directly after Form.Show(). But no matter what parameters I pass, doesn't abort the opening-animation.
I've got it! After some trying around with ShowWindow, BorderStyles I found my exact solution:
Change the initial "FormBorderStyle" property of the form to one of those:
None
FixedToolWindow
SizeableToolWindow
Add a eventhandler to the Forms "Shown" event.
Inside the eventhandler, change the FormBorderStyle to "Sizeable" (or any other).
Now the trick is that "none" and "*toolwindow" borderstyles will suppress the opening/popup animation for that form. Than, as soon as the form is being displayed the borderstyle is changed, giving it the original functionality (Icon in the Control-Bar, Minimize/Maximize Buttons etc...)
Edit: For everyone who might want to try this too, I have to point out that this can will screw with the actual size of the window when done with PInvoke commands.
If you rely on the size of the window being correct, be sure to resize the the window to its intended size after you done this.
This is part of windows visual effects and can be adjusted using the SystemParametersInfo Method.
I found that the animation is only take place when the form is shown for the first time.
So here is the trick:
var form = new Form();
form.Show();
form.Hide();
form.Show();
I tested it only in Windows 8
You can change the style before and after, like this, which will prevent the fade-out animation.
this.FormBorderStyle = FormBorderStyle.Sizable;
this.Show();
// Do whatever
this.FormBorderStyle = FormBorderStyle.Sizable;
this.Show();

how to remove the default control buttons from a windows form

The image describes what I am trying to do.
I have a "connect four" game which works perfectly well but I want to remove the default buttons provided at the top right hand corner of the window. Any quick help on this?
Click here to view steps in video
Please Set ControlBox Value as "False" of your desire form.
The ControlBox property of Forms does this after hiding the Minimize and Maximize buttons.
MSDN - Form.ControlBox Property
In the properties window for your form designer, there should be a listing for MaximizeBox and MinimizeBox that you can set to false to disable the maximize and minimize buttons on the form. AFAIK there is no way to disable the close button.

Can't keep WinKey+Up from moving my form

I am trying to set a window at the bottom right of my screen. Its FormBorderStyle is set to None. I don't want the user to have the ability to move it around. Unfortunately, if the user presses Winkey+Up (maximize in Win7), it will relocate the form to (0,0) on my desktop.
I tried resetting the location in the LocationChanged event but when I changed the Left/Top or Location properties, they would not actually change.
Does anybody have any ideas on how I can resolve this?
Thanks!
You can't programmatically change your form's location if it is maximized. You'll need to change its WindowState property to FormWindowState.Normal before trying to set its location.
You need a GlobalSystemHook, and itsn't a trivial work.
At this url (CodeProject) there is an useful example.
Set your FormBorderStyle to one of FixedSingle, Fixed3D, FixedDialog or FixedToolWindow AND set MaximizeBox and MinimizeBox to false.

C# Winforms, no resize arrow using GrowAndShrink

I have a winform with a picture box, a button, and a menustrip. The picture box is anchored to all sides so when I resize the form, the picture box resizes as well. I set the form to have a minimum size of 700x600.
But this only works when the form is set to AutoSizeMode = GrowOnly. If I change to AutoSizeMode = GrowAndShrink, the diagonal <=> resize arrow doesn't even show up.
If I set the SizeGripStyle = Show on the form, I can get the arrow to show up and "resize" but as I drag it to resize, it just flickers really fast and goes back to default size.
How can I make it GrowAndShrink instead of just GrowOnly?
Make sure the form properties have the following:
AutoSize: false (sounds like it should be true, but set this to false).
AutoSizeMode: GrowOnly (like above, sounds like it should be GrowAndShrink)
MinimumSize: Not important. set to 1, 1 for now. Is just to stop resizing getting too small.
MaximumSize: Not important. set to 1, 1. As above (MinimumSize).
SizeGripStyle: Not important. Set to Show.
Lastly, ensure that you use anchoring or docking for adjusting control widths when the form resizes. Setting controls with a width may prevent you resizing the form.
Try setting the picture box's AutoSizeMode = GrowAndShrink.
I usually leave the form's AutoSizedMode = GrowOnly, because if you forget to set some of the minimum sizes on your controls, it will always try to be the minimum size.

Dissallowing resize of a window form

I want that the user shouldn't be able to resize the window form. I was able to disable the maximize button but wasn't able to find any property to disable resizing.
Any help?
You need to set the FormBorderStyle property to one of the fixed values.
Change the FormBorderStyle to FixedSingle. Also set MinimizeBox and MaximizeBox to False. Even double clicking the title will not maximize the form.
Assuming you are talking about a WinForms form, you can disable resizing by changing the FormBorderStyle property to one of the Fixed values, such as FixedSingle. There are also MaximumSize and MinimumSize properties that may be set if you want to allow some, but not total, resizing.
If you are talking about a WPF application, then you can set the ResizeMode property to NoResize, or you can set the MaxHeight, MaxWidth, MinHeight, and MinWidth properties.
As noted in the comments for the question, make sure you have a good reason to disable resizing. Most of the time, there are better alternatives that allow resizing (especially in WPF).
Set MaximumSize and MinimumSize to the current form size
this.MaximumSize = new System.Drawing.Size(x, y);
this.MinimumSize = new System.Drawing.Size(x, y);
Change the frame/border type to a non-resizeable type.

Categories