Tech Off Thread

4 posts

How do I show a control outside the Form?

Back to Forum: Tech Off
  • User profile image
    BenDi

    Hi,

    I'm trying to make a VS-like auto-complete control and can't figure out how to display it so it isn't clipped by the main Form. In VS, it looks like that: (as you can see, the auto-complete list is not clipped by the border of the VS main form)


    I tried to put my selection list into a control which got me that far:


    Does anyone have an idea how to get a control shown over the bounds of the form? Sadly, taking another form to put it in is not an option since the thing has to be visible while the focus is on the TextBox.

    Cheers,

    B.

  • User profile image
    damoh

    It is actually on a second form. A form with FormBorderStyle = none and positioned in code. You need to show it without the form taking focus. To do that, you need to use interop. Sample code here http://www.pcreview.co.uk/forums/thread-1313358.php

    To position the form, you need get the control you want the form to appear near, and use Control.PointToScreen to get the screen coords and position the form with an offset.


  • User profile image
    BenDi

    Yup, that did the trick. Thanks!

  • User profile image
    damoh

    You're welcome Big Smile

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.