locked
Contain ToolStripDropDown within UserControl boundaries? RRS feed

  • Question

  • I have a user control I created (named 'display) that is used to represent a computer screen. I am using a ToolStrip as a 'popup menu' within this display user control.

    For the most part, things work very well, upon certain actions I display the toolstrip at a specified location within the boundaries of the user control.

    The problem I currently have is that the drop down menus will display outside of the boundaries of my display user control.

    Is there a way I can configure my toolstrip (or the toolstripdropdown) to respect the boundaries of my user control?
    What I would like to see it do is the same thing that happens when you open a menu at the edge of the real physical screen, either have the dropdown menu 'push up' from the bottom edge of the control, or push left from the right edge of the control.

    Currently, the dropdown will display outside of my user control (and even the form that contains it)

    Since there appears to be code that handles the physical screen boundaries, I would think there could be some way I could redefine the boundaries to my user control, rather than the physical screen, but I just haven't figured out what actually controls this behavior.

    If anyone has any suggestions, i'd greatly appreciate it. Thank you!
    • Moved by Michael Sun [MSFT]Microsoft employee Tuesday, October 21, 2008 9:17 AM Off Topic for Visual C# General [loc] (Moved from Visual C# General to Off-Topic Posts (Do Not Post Here))
    Wednesday, October 15, 2008 8:52 PM

Answers

  •  Hello,

           Start to understand your issue, but I think you could create a new thread at Windows Forms General forum for a better answer.   More experts on Windows Forms Controls will be glad to help you on this issue.

           Thanks,

    Best Regards,
    Lingzhi
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/csharpide/thread/8e9ed0d7-11ff-402a-8489-9b5f05eeb706 http://forums.msdn.microsoft.com/en-US/vssetup/thread/60424309-bd78-4ca2-b618-03c4a16123b6
    Tuesday, October 21, 2008 9:16 AM

All replies

  •  

    Hello,

            Could you please offer us some screenshot of your issue, to make your problem more clearly?   Also, some codes are very helpful.   And you could upload the screenshot to some server and offer us the URL.   You could easily sign up for 5GB free space at http://skydrive.live.com only with your Live Passport. 

     

            Thanks,

    Best Regards,
    Lingzhi


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/csharpide/thread/8e9ed0d7-11ff-402a-8489-9b5f05eeb706 http://forums.msdn.microsoft.com/en-US/vssetup/thread/60424309-bd78-4ca2-b618-03c4a16123b6
    Monday, October 20, 2008 6:45 AM
  • Unfortunately I do not have access (at the moment) to post screen shots to an external website.

    To replicate the issue with a standard application, do the following:

    1. Start notepad
    2. Resize the notepad window until you could only see 2 or 3 lines of text, and the width being the width of the menu strip.
    3. now, right click in the notepad text entry area.

    When the context window is displayed part of the menu will be outside of the notepad form/window.

    4. Reposition your notepad window at the bottom of the screen, so part of it is behind your taskbar.
    5. Right click to display the context menu, see how it repositions itself up, so it will not be displayed off screen?

    When I assign a toolstrip to a control within a form, the top level menu does not display outside of the control.
    however, the dropdown menu does.

    What I would like to be able to do is keep the dropdown menu within the control which owns it, not let it leave the control, or the form in which it is contained.

    Since there is code built into the toolstrip/contextmenu/etc controls that cause the menus to be repositioned when they would be drawn offscreen, it would seem that I should be able to define my own 'valid bounds rectangle' (something smaller than the screen size) and pass that to the menu controls so that if the menu were to be drawn outside of my defined bounds (rather than the screen) the menu would reposition itself.

    From research I've been doing, it seems that menus automatically reference the screen size as their bounding box, and I cannot find a way to override/redefine those settings.

    It sounds like the only thing I can do is create my own user control and define my own menu control.



    Monday, October 20, 2008 6:13 PM
  •  Hello,

           Start to understand your issue, but I think you could create a new thread at Windows Forms General forum for a better answer.   More experts on Windows Forms Controls will be glad to help you on this issue.

           Thanks,

    Best Regards,
    Lingzhi
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/csharpide/thread/8e9ed0d7-11ff-402a-8489-9b5f05eeb706 http://forums.msdn.microsoft.com/en-US/vssetup/thread/60424309-bd78-4ca2-b618-03c4a16123b6
    Tuesday, October 21, 2008 9:16 AM
  • Thanks for the suggestion. I think you are correct, this is more of a WinForms issue, than a C# issue.
    Tuesday, October 21, 2008 7:08 PM