By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,436 Members | 2,958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,436 IT Pros & Developers. It's quick & easy.

Visible controls reports not visible

P: n/a
Hi
I have a problem in one of my user controls that I cannot find any solution
for.
I'am running C# for Visual studio 2003 and developing a windows application.
The problem is the following:
I have a user control with several panels inside it. Each panel is docked at
top, which means that if one panel is hidden, the panels underneath it will
move up to cover the newly hidden area (basic information, I know, but just
to clarify :-). Forms in my application that are using this control should
adjust their heights, so that the user control fits into them, without any
blank area.
In this user control I have some properties that can be set to true/false,
which in turns shows or hides the panels.
Now to the strange thing: When hiding some of the panels, I want to change
the size of the user control not to have any blank area in it. This is done
by looping through all of the panels in the control and checking the visible
property. The panel with the location at the bottom that has its visible
property set to true decides the height of the control.
The problem is that all panels report their visible property set to false
when looping through them - always. Even if they report their visible
property to false, the panels that should be visible (according to the
properties I have) are visible, so the control behaves correctly in this
case. The problem is that the reported height of the control is not ok.
The application is only running in one thread.
Have anyone a solution to this?

/Fredrik
Aug 22 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
When a Control is hidden, by virtue of being underneath another Control, its
Visible property is false. Rather than setting the Visible property, why not
just use the BringToFront method of the Control to bring it to the top, then
resize the UserControl to fit the top Panel?

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Fredrik" <Fr*****@discussions.microsoft.comwrote in message
news:56**********************************@microsof t.com...
Hi
I have a problem in one of my user controls that I cannot find any
solution
for.
I'am running C# for Visual studio 2003 and developing a windows
application.
The problem is the following:
I have a user control with several panels inside it. Each panel is docked
at
top, which means that if one panel is hidden, the panels underneath it
will
move up to cover the newly hidden area (basic information, I know, but
just
to clarify :-). Forms in my application that are using this control should
adjust their heights, so that the user control fits into them, without any
blank area.
In this user control I have some properties that can be set to true/false,
which in turns shows or hides the panels.
Now to the strange thing: When hiding some of the panels, I want to change
the size of the user control not to have any blank area in it. This is
done
by looping through all of the panels in the control and checking the
visible
property. The panel with the location at the bottom that has its visible
property set to true decides the height of the control.
The problem is that all panels report their visible property set to false
when looping through them - always. Even if they report their visible
property to false, the panels that should be visible (according to the
properties I have) are visible, so the control behaves correctly in this
case. The problem is that the reported height of the control is not ok.
The application is only running in one thread.
Have anyone a solution to this?

/Fredrik

Aug 22 '07 #2

P: n/a
Thanks for the answer.

My bad english is also playing in this :-)
The panels are not underneeth each other, they are stacked. All panels are
in the same containter (the user control's main area). With all panel's dock
property set to TOP, they are stacked on each other meaning that if the first
panel has its location at 0,0 and a height of 100, the second panel gets its
location to 0,100 etc. When setting the first panels visible property to
false, the second panel is automatically moved to 0,0.
So my intension is to check which panel is at bottom, and is visible (with
its Location or Top property higher than other panels).
But when I check the panel's visible property, all panels have "false" even
if they are visible.
I'll try to show below how I mean in more detail:
My user control contains 4 panels, A,B,C and D, all in the same container.
They are visually as shown below:
A
B
C
D
In some cases, I want to hide panels C or D. Lets assume that panel C is to
be hidden. When setting the visible property to false for panel C, panel D
moves up to panel C's old position (due to the dock property). Then I want to
check their visible property, but this always return false.
I've seen then phenomena when setting properties for visual controls from
another thread, but in this case I only have 1 thread.

Long explenation, but hope it will show what I want, and explain more in
detail what my problem is.
/Fredrik

"Kevin Spencer" wrote:
When a Control is hidden, by virtue of being underneath another Control, its
Visible property is false. Rather than setting the Visible property, why not
just use the BringToFront method of the Control to bring it to the top, then
resize the UserControl to fit the top Panel?

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Fredrik" <Fr*****@discussions.microsoft.comwrote in message
news:56**********************************@microsof t.com...
Hi
I have a problem in one of my user controls that I cannot find any
solution
for.
I'am running C# for Visual studio 2003 and developing a windows
application.
The problem is the following:
I have a user control with several panels inside it. Each panel is docked
at
top, which means that if one panel is hidden, the panels underneath it
will
move up to cover the newly hidden area (basic information, I know, but
just
to clarify :-). Forms in my application that are using this control should
adjust their heights, so that the user control fits into them, without any
blank area.
In this user control I have some properties that can be set to true/false,
which in turns shows or hides the panels.
Now to the strange thing: When hiding some of the panels, I want to change
the size of the user control not to have any blank area in it. This is
done
by looping through all of the panels in the control and checking the
visible
property. The panel with the location at the bottom that has its visible
property set to true decides the height of the control.
The problem is that all panels report their visible property set to false
when looping through them - always. Even if they report their visible
property to false, the panels that should be visible (according to the
properties I have) are visible, so the control behaves correctly in this
case. The problem is that the reported height of the control is not ok.
The application is only running in one thread.
Have anyone a solution to this?

/Fredrik


Aug 22 '07 #3

P: n/a
Hi Fredrik,

That is odd. I have not tried something similar, but I will take your word
that this is what you are seeing.

I suppose you will have to implement a tracking mechanism to keep track of
the state of the Panels when it changes.

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Fredrik" <Fr*****@discussions.microsoft.comwrote in message
news:2E**********************************@microsof t.com...
Thanks for the answer.

My bad english is also playing in this :-)
The panels are not underneeth each other, they are stacked. All panels are
in the same containter (the user control's main area). With all panel's
dock
property set to TOP, they are stacked on each other meaning that if the
first
panel has its location at 0,0 and a height of 100, the second panel gets
its
location to 0,100 etc. When setting the first panels visible property to
false, the second panel is automatically moved to 0,0.
So my intension is to check which panel is at bottom, and is visible (with
its Location or Top property higher than other panels).
But when I check the panel's visible property, all panels have "false"
even
if they are visible.
I'll try to show below how I mean in more detail:
My user control contains 4 panels, A,B,C and D, all in the same container.
They are visually as shown below:
A
B
C
D
In some cases, I want to hide panels C or D. Lets assume that panel C is
to
be hidden. When setting the visible property to false for panel C, panel D
moves up to panel C's old position (due to the dock property). Then I want
to
check their visible property, but this always return false.
I've seen then phenomena when setting properties for visual controls from
another thread, but in this case I only have 1 thread.

Long explenation, but hope it will show what I want, and explain more in
detail what my problem is.
/Fredrik

"Kevin Spencer" wrote:
>When a Control is hidden, by virtue of being underneath another Control,
its
Visible property is false. Rather than setting the Visible property, why
not
just use the BringToFront method of the Control to bring it to the top,
then
resize the UserControl to fit the top Panel?

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Fredrik" <Fr*****@discussions.microsoft.comwrote in message
news:56**********************************@microso ft.com...
Hi
I have a problem in one of my user controls that I cannot find any
solution
for.
I'am running C# for Visual studio 2003 and developing a windows
application.
The problem is the following:
I have a user control with several panels inside it. Each panel is
docked
at
top, which means that if one panel is hidden, the panels underneath it
will
move up to cover the newly hidden area (basic information, I know, but
just
to clarify :-). Forms in my application that are using this control
should
adjust their heights, so that the user control fits into them, without
any
blank area.
In this user control I have some properties that can be set to
true/false,
which in turns shows or hides the panels.
Now to the strange thing: When hiding some of the panels, I want to
change
the size of the user control not to have any blank area in it. This is
done
by looping through all of the panels in the control and checking the
visible
property. The panel with the location at the bottom that has its
visible
property set to true decides the height of the control.
The problem is that all panels report their visible property set to
false
when looping through them - always. Even if they report their visible
property to false, the panels that should be visible (according to the
properties I have) are visible, so the control behaves correctly in
this
case. The problem is that the reported height of the control is not ok.
The application is only running in one thread.
Have anyone a solution to this?

/Fredrik



Aug 23 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.