Have a ListBox with a Textbox autocomplete when I type a key and it has many results, my form moves all the other controls. I try to find some way for the Listbox to appear in front of the form as "zindex" or something like that. sorry for my bad English.
Loading

Sandhiya PriyaRank #26 · 43.2K reputationPosted Oct 27, 2025, 5:04 AM EDT
Your English is totally fine — and your question is very clear!
You’re describing a WinForms (Windows Forms) scenario:
You have a TextBox with autocomplete results shown in a ListBox, and when the ListBox displays many results, it pushes or moves other controls on the form. You want the ListBox to float on top, similar to a “z-index” in HTML/CSS.
Let’s fix that
Problem
When you add a
ListBoxdirectly inside the form’s layout (like in aPanel,TableLayoutPanel, or similar), it participates in the form’s layout and causes other controls to move or resize.Solution 1: Show ListBox as a Floating Control (Independent Layer)
You can make the ListBox overlay other controls by setting it to
TopMostand managing its position manually.Here’s a simple example:
public partial class Form1 : Form { ListBox lstSuggestions = new ListBox(); public Form1() { InitializeComponent(); // Initialize the ListBox lstSuggestions.Visible = false; lstSuggestions.Height = 100; lstSuggestions.Width = 200; lstSuggestions.BringToFront(); // makes it appear above other controls this.Controls.Add(lstSuggestions); textBox1.KeyUp += TextBox1_KeyUp; lstSuggestions.Click += LstSuggestions_Click; } private void TextBox1_KeyUp(object sender, KeyEventArgs e) { string text = textBox1.Text.ToLower(); if (string.IsNullOrWhiteSpace(text)) { lstSuggestions.Visible = false; return; } // Example items var allItems = new List { "Apple", "Apricot", "Banana", "Blueberry", "Cherry" }; var filtered = allItems.Where(x => x.ToLower().StartsWith(text)).ToList(); if (filtered.Count > 0) { lstSuggestions.DataSource = filtered; lstSuggestions.Visible = true; // Position the ListBox just below the TextBox lstSuggestions.Left = textBox1.Left; lstSuggestions.Top = textBox1.Bottom; lstSuggestions.BringToFront(); // ensure it's on top } else { lstSuggestions.Visible = false; } } private void LstSuggestions_Click(object sender, EventArgs e) { textBox1.Text = lstSuggestions.SelectedItem.ToString(); lstSuggestions.Visible = false; } }What this does:
Keeps the ListBox hidden until there are results.
Positions it directly below the TextBox.
Calls
.BringToFront()so it overlaps other controls (like a popup).Does not move other controls anymore.
Solution 2: Use a Separate
Formas Popup (Best for Professional Look)If you want it to behave like a dropdown (similar to IntelliSense or combo box), create a small borderless Form and show it near your TextBox.
Form suggestionForm = new Form(); ListBox lstSuggestions = new ListBox(); private void InitializeSuggestionsPopup() { suggestionForm.FormBorderStyle = FormBorderStyle.None; suggestionForm.ShowInTaskbar = false; suggestionForm.TopMost = true; lstSuggestions.Dock = DockStyle.Fill; suggestionForm.Controls.Add(lstSuggestions); } private void ShowSuggestions(Point location) { suggestionForm.Location = location; suggestionForm.Size = new Size(200, 100); suggestionForm.Show(); }This gives you a clean floating popup that never interferes with other controls.
Summary
Sam HobbsRank #107 · 20.5K reputationPosted Oct 27, 2025, 8:19 PM EDT
If all the other controls means items in the ListBox then you are describing a ComboBox. There are various names for (types of) ComboBoxes. The name ComboBox refers to a combination of a ListBox and a TextBox although in the Windows API TextBoxes are called Edit Controls.
balaka6 reputationPosted Oct 27, 2025, 11:58 PM EDT
Cookie Clicker has revolutionized the idle gaming genre since its creation in 2013. This deceptively simple yet incredibly engaging game has captured the hearts of millions of players worldwide, turning a basic concept into a global phenomenon.