1

I have a created a custom user control which consists of 2 controls:-

  1. Textbox
  2. Listbox

The function of this control is to act as a dropdown list. Below is the image of the control:-

enter image description here

Problem

Now the problem i am facing is that if i insert this user control into a container control like a panel then the list gets hidden inside that container control.

enter image description here

and if i just create the user control outside the container control then it would interfere with the Tab Order (focus order) of the form.


Is there any work around where the user control exists in the container control and still shows the complete list without being hidden in the panel?

Edit i wrongly added c# instead of VB.NET

Agent_Spock
  • 1,107
  • 2
  • 16
  • 44
  • Have you tried with `meListControl.BringToFront();` ? – mrogal.ski Sep 14 '17 at 12:18
  • @m.rogalski yes it is already implemented in the code but the list still gets hidden because of the container control. – Agent_Spock Sep 14 '17 at 12:20
  • Possible duplicate of [How to create a C# Winforms Control that hovers](https://stackoverflow.com/questions/353561/how-to-create-a-c-sharp-winforms-control-that-hovers) - Perhaps consider extending the stock ComboBox which implements this functionality out of the box. – Alex K. Sep 14 '17 at 12:22
  • Try with this WinAPI call : [`SetWindowPos(meListControl.Handle(), HWND_TOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms633545(v=vs.85).aspx) – mrogal.ski Sep 14 '17 at 12:23
  • @m.rogalski can you please tell how to implement it in vb.net, i am new to VB.net. – Agent_Spock Sep 14 '17 at 12:26
  • @Agent_Spock When I was writing this comment it was tagged with C#... You can check [pinvoke.net](http://pinvoke.net/default.aspx/user32/SetWindowPos.html) for definition. – mrogal.ski Sep 14 '17 at 12:27
  • @m.rogalski yeah i had a look into it but couldn't find what is `SWP_SHOWWINDOW` – Agent_Spock Sep 14 '17 at 12:29
  • @Agent_Spock From the documentation it says ( `SWP_SHOWWINDOW = 0x0040` ). Just look at the links I've posted. – mrogal.ski Sep 14 '17 at 12:31
  • @m.rogalski i tried it but it did not work – Agent_Spock Sep 14 '17 at 12:43

1 Answers1

0

It can be achieved by having the list as ToolStripDropDown. Similar customization have been done in the following discussion,

Show control inside user control outside the boundaries of its parent

Hope this suits you.

christo issac
  • 440
  • 3
  • 12