Windows Application: Drawing control over boundaries?

T

Ty

Hi all

following scenario: i have a usercontrol with a search-textbox who
opens a datagrid to show filtered records. unfortunatly this datagrid
is limited to the boundaries of the usercontrol wich limits the height
to some 4 records. (i know i could use a normal dropdowncontrol, but
this is not good enough for some reasons).
right now i've solved it by opening a new borderless form wich is
aligned to the search-textbox. needless to say, this approach is
difficult to handle because this dumy-form is somewhat disconnected to
the searchtextbox.

in general, is it possible to draw a control or usercontrol somewhere
outside it's containers boundaries, somewhere on the screen?

Thank You!
 
T

Ty

Define "draw".  You certainly can place the control in that way.  Andyou  
can draw the control in the sense that the display code responsible for  
rendering the control can execute normally.

But if you mean "can the control actually be _visible_ outside the parent 
container", the answer is generally no.  The child control is clipped to  
the parent.

One option would be to set the AutoScroll property of the UserControl to  
"true", so that at least the user could scroll to see all of the DataGrid..

Another alternative would be to not display the DataGrid inside the  
UserControl itself.  You could either do it the way you're doing it now,  
or just abandon the idea of having the DataGrid physically connected to  
the TextBox and show it as a modeless dialog or something like that.

Pete


Thanks Pete

i wanted to know if there are better options out there, so "no" as an
answer is also good ;). right now im showing it as borderless form.
but there's a lot of event handling that has to go on (if form
resizes, moves, application loses focus etc etc).
the other thing i could do is showing the grid on the parent form of
the usercontrol, easier to handle. disadvantage is that i'm limited to
the form borders, whereas a combobox can show it's list over the
formborders. from a user standpoint it would really be better to have
it as big as neccessary, and i hate to make compromises for technical
reasons...

oh well :)

solutions still welcome

thanks and have a nice day
 
T

Ty

Define "draw".  You certainly can place the control in that way.  Andyou  
can draw the control in the sense that the display code responsible for  
rendering the control can execute normally.

But if you mean "can the control actually be _visible_ outside the parent 
container", the answer is generally no.  The child control is clipped to  
the parent.

One option would be to set the AutoScroll property of the UserControl to  
"true", so that at least the user could scroll to see all of the DataGrid..

Another alternative would be to not display the DataGrid inside the  
UserControl itself.  You could either do it the way you're doing it now,  
or just abandon the idea of having the DataGrid physically connected to  
the TextBox and show it as a modeless dialog or something like that.

Pete


in the meanwhile i came up with another solution. by pure chance i
figured out that every control that is added to the controls
collection of the mdiparent is always on top of everything else.

this allows to simply add any usercontrol to mdiparent.contols, place
it where you want (eg under the searchtextbox), connect the move-event
on the mdiparent to move the usercontrol acordingly. remove the
usercontrol when the form deactivates or closes. it's quite easy to
handle and works without any flickering or hitches. of course this
works only inside a mdiparent.

greetz
 

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