title: Allow a ListBox to overlap a TableLayoutPanel (C# .NET)
body: <p>I have a form that contains a TableLayoutPanel with various controls and labels in it. One of them is a custom control that inherits from ComboBox that has extra auto-complete behavior (auto-completes on any text rather than just left to right). I didn't write the code for this control, so I'm not super familiar with how it works, but essentially upon clicking on the Combobox, it adds a ListBox below the ComboBox, within the same Panel of the TableLayoutPanel, that covers the normal drop down. </p>
  
  <p>Unfortunately, the TableLayoutPanel prevents the ListBox from being fully visible when added, and only one item is shown. The goal is to get it to look like a normal ComboBox which would drop down to cover any controls below it.  </p>
  
  <p>Is there any way to allow a control that is in a TableLayoutPanel to overlap the TableLayoutPanel to get this to work as I want? I want to avoid any controls moving around due to the TableLayoutPanel growing to accommodate the ListBox.</p>
  
  <p>Relevant code from the control:</p>
  
  <pre><code>void InitListControl()
          {
              if (listBoxChild == null)
              {
                  // Find parent - or keep going up until you find the parent form
                  ComboParentForm = this.Parent;
  
                  if (ComboParentForm != null)
                  {
                      // Setup a messaage filter so we can listen to the keyboard
                      if (!MsgFilterActive)
                      {
                          Application.AddMessageFilter(this);
                          MsgFilterActive = true;
                      }
  
                      listBoxChild = listBoxChild = new ListBox();
                      listBoxChild.Visible = false;
                      listBoxChild.Click += listBox1_Click;
                      ComboParentForm.Controls.Add(listBoxChild);
                      ComboParentForm.Controls.SetChildIndex(listBoxChild, 0); // Put it at the front
                  }
              }
          }
  
  
          void ComboListMatcher_TextChanged(object sender, EventArgs e)
          {
              if (IgnoreTextChange &gt; 0)
              {
                  IgnoreTextChange = 0;
                  return;
              }
  
              InitListControl();
  
              if (listBoxChild == null)
                  return;
  
              string SearchText = this.Text;
  
              listBoxChild.Items.Clear();
  
              // Don't show the list when nothing has been typed
              if (!string.IsNullOrEmpty(SearchText))
              {
                  foreach (string Item in this.Items)
                  {
                      if (Item != null &amp;&amp; Item.ToLower().Contains(SearchText.ToLower()))
                      {
                          listBoxChild.Items.Add(Item);
                          listBoxChild.SelectedIndex = 0;
                      }
                  }
              }
  
              if (listBoxChild.Items.Count &gt; 0)
              {
                  Point PutItHere = new Point(this.Left, this.Bottom);
                  Control TheControlToMove = this;
  
                  PutItHere = this.Parent.PointToScreen(PutItHere);
  
                  TheControlToMove = listBoxChild;
                  PutItHere = ComboParentForm.PointToClient(PutItHere);
  
                  TheControlToMove.Anchor = ((System.Windows.Forms.AnchorStyles)
                      ((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
                  TheControlToMove.BringToFront();
                  TheControlToMove.Show();
                  TheControlToMove.Left = PutItHere.X;
                  TheControlToMove.Top = PutItHere.Y;
                  TheControlToMove.Width = this.Width;
  
                  int TotalItemHeight = listBoxChild.ItemHeight * (listBoxChild.Items.Count + 1);
                  TheControlToMove.Height = Math.Min(ComboParentForm.ClientSize.Height - TheControlToMove.Top, TotalItemHeight);
              }
              else
                  HideTheList();
          }
  </code></pre>
  
  <p>Images:</p>
  
  <p><a href="http://i.stack.imgur.com/FvCoE.jpg" rel="nofollow">Desired behavior</a></p>
  
  <p><a href="http://i.stack.imgur.com/Q3pDd.jpg" rel="nofollow">Current behavior</a></p>