Placing a control above another control;.

K

ketaki

Hello,
I am new to C# and I am facing a problem. I have two user
controls.First control has an image which is loaded. And the second
control is supposed to be placed on the first control. But when the
first control is invalidated the second control gets hidden behind the
first control and it becomes invisible. Once I invalidate the second
control it appears on top of the first control for fraction of second
and again gets hidden. I want the second control to be seen
permanently on the first control even wheen the first control is
invalidated. I tried "Send to back" and "Bring to front" options but
they do not seem to be solving my problem.
Please help.
Thanks
 
M

Michael Nemtsev [MVP]

Hello ketaki,

asp.net or winforms?!


---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


k> Hello,
k> I am new to C# and I am facing a problem. I have two user
k> controls.First control has an image which is loaded. And the second
k> control is supposed to be placed on the first control. But when the
k> first control is invalidated the second control gets hidden behind
k> the
k> first control and it becomes invisible. Once I invalidate the second
k> control it appears on top of the first control for fraction of second
k> and again gets hidden. I want the second control to be seen
k> permanently on the first control even wheen the first control is
k> invalidated. I tried "Send to back" and "Bring to front" options but
k> they do not seem to be solving my problem.
k> Please help.
k> Thanks
 
P

Peter Duniho

[...] I want the second control to be seen
permanently on the first control even wheen the first control is
invalidated. I tried "Send to back" and "Bring to front" options but
they do not seem to be solving my problem.

You should post a concise-but-complete sample of code that reliably
demonstrates the problem. There's just not enough specific information in
your question for anyone to understand for sure just how you are putting
your form and its controls together.

That said, some things that may be useful to you: controls are ordered
visually according to their order in the Controls property of the parent
control, with the first control (0 index) being on top. Also, controls
that act as containers can wind up with other controls added to same form
as their children, depending on where those other controls were placed. A
child control will obscure a parent control no matter what you do with the
z-order.

Usually this sort of thing would show up right away. After all, the first
thing that happens before you ever see a form is that it's invalidated and
requires painting. If the only thing causing your issue was in fact
invalidation (i.e. calling Invalidate()), it seems odd that it would
happen only after the form was first shown, as your message implies.

But then, your question was presented in a pretty vague way. So who knows
what's really going on except you. That's why a concise-but-complete
sample would be useful.

Pete
 

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