1

I've created a Custom ComboBox, but there's one thing I've been stuck on for weeks, and still nothing to show for it because I just can't figure it out. I have tried searching online, and I've not been able to find any info about it.

What I'm trying to do is, allow the list part of the combobox (the part that drops down and displays the list) to be shown outside the bounds of the Form, like this:

ComboBox displaying its list outside the bounds of its containing control.

I'm not sure why I've not been able to find anything related to this - maybe I'm not searching using the right terminology. But I've never done this before, so I don't even know what to call it.

How do I get part of my control to display outside the bounds of the form/its parent?

SE13013
  • 343
  • 3
  • 14
  • 1
    I know combox in winform does that automatically. Can you post some info on how did you do your custom combox? – jtabuloc Jul 25 '15 at 04:15
  • It's a fully custom drawn custom control. I am not extending from the winforms combobox. I make custom controls, I don't clone existing ones. Knowing how to do this would also be beneficial for other custom controls that need to be shown outside of the bounds of the parent. – SE13013 Jul 25 '15 at 04:18
  • 1
    So what is the current behavior of your custom combo-box right now? Does it show upward when you click? or Does it hide inside your form as hidden overflow? It will be helpful if you can post your code. – jtabuloc Jul 25 '15 at 04:25
  • 1
    Go peruse the code in Lukasz Swiatkowski's [Simple Popup Control](http://www.codeproject.com/Articles/17502/Simple-Popup-Control) over at CodeProject.com. – Idle_Mind Jul 25 '15 at 04:49
  • JTC I do apologise, there isn't really any helpful code I can show. It's just a bunch of GDI drawing code that draws "a combobox" within its bounds. – SE13013 Jul 25 '15 at 04:56
  • 1
    I doubt you can do that. I guess ComboBox does some rather non-standard things under the hoods.. – TaW Jul 25 '15 at 09:44
  • It's not just comboboxes that do it. It's any kind of menu on any operating system! How can this not be doable? Right click near an edge of a browser window... Context menu displays outside of its parents bounds. – SE13013 Jul 25 '15 at 09:46
  • 2
    You could create a new window with no borders and simply add the control to that window, put it to the front and that way you match the size of the window to your control. The window should NOT be a child window of the main window, otherwise it will not be able to do this. It's a bit of a "hacky" procedure, but I think the real implementation is done at the system level and isn't really something easy (if even possible) to mess around with. If you want I could try to come up with something – Bauss Jul 25 '15 at 12:25
  • I don't like that. Sounds too hacky to me. I'd rather not do it at all if that's the only option. – SE13013 Jul 25 '15 at 12:40
  • 1
    Well you can decide yourself, I made something up that works okay. http://prntscr.com/7wtb3u – Bauss Jul 25 '15 at 12:51
  • 1
    _It's not just comboboxes that do it. It's any kind of menu on any operating system!_ - Well, that makes it `ComboBoxDropDowns` and `MenueDropDowns`. Still only __two exceptions__ to the rule that a control is a rectangular piece of screen estate.. (Forms are Controls, too). I would guess that those two exceptions were _hacked_ into the system to make them work.. – TaW Jul 25 '15 at 15:22
  • 1
    `ToolTip`s make any control behave this way. – C.Evenhuis Jul 25 '15 at 18:19
  • 1
    I hope I haven't come across as being ungrateful or rude in my comments. I just have this thing where I've had to do a lot of hacky things in my personal projects to achieve desired results, and I always end up finding "the proper way" do to it later... I've been trying out a few things based on your suggestions. Thanks for all of your help! :-) I do have an idea I'll see how it goes and will leave an update. – SE13013 Jul 26 '15 at 04:28
  • 1
    _ToolTips make any control behave this way._ OK, so the count is three now. But note: None of these controls actually leaves the rectangle, they all just show another rectangle which may well be another form under the hoods.. So Bauss still suggestion seems like the way to go.. – TaW Jul 26 '15 at 09:48
  • Yeah, it sure does. All good suggestions. I just feel like I'm committing a terrible "sin" by doing this. It's like spelling your name with a lowercase t and an uppercase w. Still works, but doesn't feel right. – SE13013 Jul 26 '15 at 09:52
  • See [How to simulate a drop-down window in WinForms?](http://stackoverflow.com/q/8661670/719186) – LarsTech Jul 26 '15 at 17:32
  • 1
    _lowercase t and an uppercase w_ no me, Sir! ;-) – TaW Jul 26 '15 at 17:50

0 Answers0