473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Changing Visible property in Form changes location.

I have an MDI container with a child Form which will be visible according to
certain events. The problem is that when I set the property Visible to False
and then back to True, the Form will be in another location, or it will be
maximized.

Why does the child Form change its location when the Visible propery is set
true (after being set to False)? Why doesn't it stay with the same Size and
the same Location?

Thanks.
Jul 5 '07 #1
8 3989
Doc,

Can you show an example where this happens? When setting the Visible
property to false, then back to true (I have a timer make the form visible
again) it comes back in the same place.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Doc John" <no emailwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>I have an MDI container with a child Form which will be visible according
to certain events. The problem is that when I set the property Visible to
False and then back to True, the Form will be in another location, or it
will be maximized.

Why does the child Form change its location when the Visible propery is
set true (after being set to False)? Why doesn't it stay with the same
Size and the same Location?

Thanks.

Jul 5 '07 #2
Thanks for the post.

I have an MDI Container and a TabControl docked to the left (similar to the
Outlook interface). This tab control has two buttons: One that instantiates
the child Form frm_listBrowse, and another button (button_visible) that
calls a procedure in frm_listBrowse that sets the Visible property to false.
Assuming that I've already created an instance of frm_listBrowse, this is
the code in button_invisible in my tabcontrol:

Form[] childForm = this.MdiChildren;
Form_base myForm = new Form_base(); //all Forms inherit from Form_base
which includes method hideForm() and displayForm().
Form f;

for (int i = 0; i < childForm.Length; i++)
{
if (childForm[i].Name == "frm_listBrowse")
{
f = (Form)childForm[i];
myForm = f as frm_listBrowse;
if (!isSeen) // isSeen lets me know the status of the Form- Visible
or not
{
myForm.displayForm(); //sets Visible to true
isSeen = true;
}
else
{
myForm.hideForm(); //sets Visible to false
isSeen = false;
}
}
}


"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:O2**************@TK2MSFTNGP03.phx.gbl...
Doc,

Can you show an example where this happens? When setting the Visible
property to false, then back to true (I have a timer make the form visible
again) it comes back in the same place.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Doc John" <no emailwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>I have an MDI container with a child Form which will be visible according
to certain events. The problem is that when I set the property Visible to
False and then back to True, the Form will be in another location, or it
will be maximized.

Why does the child Form change its location when the Visible propery is
set true (after being set to False)? Why doesn't it stay with the same
Size and the same Location?

Thanks.


Jul 5 '07 #3
Well, that is by no means a complete example. The displayForm and
hideForm methods are doing something, and I imagine that the code that is
moving the forms is located somewhere in those methods.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Doc John" <no emailwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Thanks for the post.

I have an MDI Container and a TabControl docked to the left (similar to
the Outlook interface). This tab control has two buttons: One that
instantiates the child Form frm_listBrowse, and another button
(button_visible) that calls a procedure in frm_listBrowse that sets the
Visible property to false.
Assuming that I've already created an instance of frm_listBrowse, this is
the code in button_invisible in my tabcontrol:

Form[] childForm = this.MdiChildren;
Form_base myForm = new Form_base(); //all Forms inherit from Form_base
which includes method hideForm() and displayForm().
Form f;

for (int i = 0; i < childForm.Length; i++)
{
if (childForm[i].Name == "frm_listBrowse")
{
f = (Form)childForm[i];
myForm = f as frm_listBrowse;
if (!isSeen) // isSeen lets me know the status of the Form- Visible
or not
{
myForm.displayForm(); //sets Visible to true
isSeen = true;
}
else
{
myForm.hideForm(); //sets Visible to false
isSeen = false;
}
}
}


"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote
in message news:O2**************@TK2MSFTNGP03.phx.gbl...
>Doc,

Can you show an example where this happens? When setting the Visible
property to false, then back to true (I have a timer make the form
visible again) it comes back in the same place.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Doc John" <no emailwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>>I have an MDI container with a child Form which will be visible according
to certain events. The problem is that when I set the property Visible to
False and then back to True, the Form will be in another location, or it
will be maximized.

Why does the child Form change its location when the Visible propery is
set true (after being set to False)? Why doesn't it stay with the same
Size and the same Location?

Thanks.



Jul 5 '07 #4
The methods hideForm() and displayForm() each have one line: "this.Visible =
false;" and "this.visible = true;".

I also created a new Form that also inherited from Form_base to see if it
had something to do with my Form, but it does the same thing. It moves about
1/2-inch to the bottom and to the right. After about five clicks, it'll move
back to the top.

Thanks again.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:OB**************@TK2MSFTNGP02.phx.gbl...
Well, that is by no means a complete example. The displayForm and
hideForm methods are doing something, and I imagine that the code that is
moving the forms is located somewhere in those methods.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Doc John" <no emailwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>Thanks for the post.

I have an MDI Container and a TabControl docked to the left (similar to
the Outlook interface). This tab control has two buttons: One that
instantiates the child Form frm_listBrowse, and another button
(button_visible) that calls a procedure in frm_listBrowse that sets the
Visible property to false.
Assuming that I've already created an instance of frm_listBrowse, this is
the code in button_invisible in my tabcontrol:

Form[] childForm = this.MdiChildren;
Form_base myForm = new Form_base(); //all Forms inherit from Form_base
which includes method hideForm() and displayForm().
Form f;

for (int i = 0; i < childForm.Length; i++)
{
if (childForm[i].Name == "frm_listBrowse")
{
f = (Form)childForm[i];
myForm = f as frm_listBrowse;
if (!isSeen) // isSeen lets me know the status of the Form-
Visible or not
{
myForm.displayForm(); //sets Visible to true
isSeen = true;
}
else
{
myForm.hideForm(); //sets Visible to false
isSeen = false;
}
}
}


"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote
in message news:O2**************@TK2MSFTNGP03.phx.gbl...
>>Doc,

Can you show an example where this happens? When setting the Visible
property to false, then back to true (I have a timer make the form
visible again) it comes back in the same place.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Doc John" <no emailwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
I have an MDI container with a child Form which will be visible
according to certain events. The problem is that when I set the property
Visible to False and then back to True, the Form will be in another
location, or it will be maximized.

Why does the child Form change its location when the Visible propery is
set true (after being set to False)? Why doesn't it stay with the same
Size and the same Location?

Thanks.



Jul 5 '07 #5
StartupPosition has to be set to Manual.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:OB**************@TK2MSFTNGP02.phx.gbl...
Well, that is by no means a complete example. The displayForm and
hideForm methods are doing something, and I imagine that the code that is
moving the forms is located somewhere in those methods.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Doc John" <no emailwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>Thanks for the post.

I have an MDI Container and a TabControl docked to the left (similar to
the Outlook interface). This tab control has two buttons: One that
instantiates the child Form frm_listBrowse, and another button
(button_visible) that calls a procedure in frm_listBrowse that sets the
Visible property to false.
Assuming that I've already created an instance of frm_listBrowse, this is
the code in button_invisible in my tabcontrol:

Form[] childForm = this.MdiChildren;
Form_base myForm = new Form_base(); //all Forms inherit from Form_base
which includes method hideForm() and displayForm().
Form f;

for (int i = 0; i < childForm.Length; i++)
{
if (childForm[i].Name == "frm_listBrowse")
{
f = (Form)childForm[i];
myForm = f as frm_listBrowse;
if (!isSeen) // isSeen lets me know the status of the Form-
Visible or not
{
myForm.displayForm(); //sets Visible to true
isSeen = true;
}
else
{
myForm.hideForm(); //sets Visible to false
isSeen = false;
}
}
}


"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote
in message news:O2**************@TK2MSFTNGP03.phx.gbl...
>>Doc,

Can you show an example where this happens? When setting the Visible
property to false, then back to true (I have a timer make the form
visible again) it comes back in the same place.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Doc John" <no emailwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
I have an MDI container with a child Form which will be visible
according to certain events. The problem is that when I set the property
Visible to False and then back to True, the Form will be in another
location, or it will be maximized.

Why does the child Form change its location when the Visible propery is
set true (after being set to False)? Why doesn't it stay with the same
Size and the same Location?

Thanks.



Jul 5 '07 #6
Hi Doc,
It moves about 1/2-inch to the bottom and to the right. After about five
clicks, it'll move back to the top.

I performed a test changing the Visible property of an MDI child form. I
see the same thing as you decribed in the above sentence. This is because
the MDI parent controls the location of its MDI child form when the MDI
child is shown in it.

In my test, I don't reproduce that the MDI child form becomes maximized
when its Visible property is set to true (originally it's false). Maybe the
WindowState property of the MDI child form is changed somewhere else in
your application.

As you have pointed out, we could set the MDI child form's StartupPosition
property to Manual, so that the MDI parent won't influence the location of
its MDI child form when the MDI child form is shown.

If you have any concern, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 6 '07 #7
On Jul 5, 1:16 pm, "Doc John" <no emailwrote:
for (int i = 0; i < childForm.Length; i++)
{
if (childForm[i].Name == "frm_listBrowse")
{
f = (Form)childForm[i];
myForm = f as frm_listBrowse;
if (!isSeen) // isSeen lets me know the status of the Form- Visible
or not
{
myForm.displayForm(); //sets Visible to true
isSeen = true;
}
else
{
myForm.hideForm(); //sets Visible to false
isSeen = false;
}
}
}
I am curious, correct me if I'm wrong but this method seems to set the
child form to visible if it is not visible and to hide if it is. Is
that correct?

Why have a method (displayform, hideForm) that sets the visible
property? Why not just use:

myForm.Visible = true;

and instead of using your isSeen variable, why not just use:

if (!myForm.Visible)

and finally, if you're just toggling the visibility of the form, why
use a big if statement instead of something like this:

myForm.Visible = !myForm.Visible;

Just wondering.

Chris

Jul 6 '07 #8
Hi Doc,

How about the problem now?

If you still need our further assistance, please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support

Jul 10 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jeff | last post by:
Hi all, I have a panel which I can't set to be visible. I explicitly set panel.Visible = true, but when I debug and go over that line, the watch window still displays it as false. Even trying...
1
by: mike | last post by:
Hi, I'd like advice from a .NETer. I have a loadcombo routine which sets the selectedindex to -1 if it's an "add record", but then it goes to a security routine which, based on permissions...
5
by: Lucvdv | last post by:
Can anyone explain why this happens with the code at the bottom? It looked like a thread safety issue, but changing the declaration of Label1 to Shared doesn't help. Standard windows form;...
6
by: Marc Robitaille | last post by:
Hello, Hello, I developed a UserControl. It has funny behavior. It is composed of three controls. A texbox, a combobox and a button. There are three properties to indicate the visibility of...
6
by: Robert | last post by:
Quick question about the visible property on a form control. I have a label that displays a message if a certain criteria is met. By default the label is visible. I want access to compare a...
0
by: landesjoe | last post by:
Hi, here's my problem in short: Text boxes in gridview don't seem to hold their value if the column's .Visible property is changed back and forth. I've got a form with a gridview populated from...
3
by: Mark B | last post by:
I have a gridview that contains a linkButton in a template field. I want to set the visibility of the linkbutton based on a bit field in a database. Selecting the proper field in editbindings...
1
by: paquer | last post by:
I have a form with a field who's Visible property by default is set to false. If another field meets a certain criteria, then the visible property is set to true. This form shows multiple...
5
by: =?Utf-8?B?VGVycnk=?= | last post by:
Hi, I have a couple of labels on a form and their visible property is bound to boolean properties on a custom object. When I first load the form, all works as it should. This form is 'tied'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.