Form resizing not by context menu

S

Sharon

Hello Tech Gurus,


I'm opening a from from another form, but this child form can not be resized
by grabbing its sided or corners, instead I need to open it's caption context
menu and choose Size or Move.

Why Is that?
How do I change it so I'll be able to resize it by grabbing its sides and/or
corners?
 
M

Marc Gravell

Well, how are you showing the form? What is the child's FormBorderStyle?
Sizable or SizableToolWindow should give you this...

Marc
 
S

Sharon

The child's FormBorderStyle is Sizable.
I have checked all properties of the child form, and they all the same as
all of my other forms.

But, as you pointed out, I am showing the child form by using it's Visible
properly, and this is what causing it to be sized the way it does.
I tried also using the Show() method, but it also had the same resizing
behavior.
Only when using the ShowDialog() the resizing behaves like I want it to. But
using the ShowDialog() is not good for me, I need the owner Form to be active
for the user when the child form is shown.

How can I do that?
 
M

Marc Gravell

Following seems fine... are you doing something different?

using System;
using System.Windows.Forms;

static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
using (Form parent = new Form())
using (Button btn = new Button())
{
parent.Text = "Parent";
btn.Text = "Show child";
int counter = 0;
btn.Click += delegate
{
Form child = new Form();
child.Text = "Child " + (counter++).ToString();
child.Show();
};
parent.Controls.Add(btn);
Application.Run(parent);

}

}
}
 
S

Sharon

Your sample works fine exactly I need it to.

Naturally, in my case it involved much more code then just opening the forms.
But I'm creating the child form, and in later stage, whenever the user asks
to, I'm showing the form by it property Visible, replacing the Visible to
Show() and Hide() didn't make any difference.

It looks strange, I don't know what can cause this kind of behavior.
Ant Idea?
 
S

Sharon

Finally I have found the cause.
It the form property AutoSizeMode that was set to GrowAndShrink. Setting it
to GrowOnly or simply removing it from the form designer file (it's the
default value), solve the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top