Dear all,
I want to create a textbox with drop down or combobox without arrow on right side but it should have drop down.
can any one tell me how i can go ahead.
-AshutoshWindows Forms General
Dear all,
I want to create a textbox with drop down or combobox without arrow on right side but it should have drop down.
can any one tell me how i can go ahead.
-AshutoshPerhaps what you want to do if you're using .NET 2.0 is hook into the AutoComplete features built into alot of the .NET components
textBox1.AutoCompleteSource =
AutoCompleteSource.CustomSource;textBox1.AutoCompleteCustomSource.AddRange(
new String[] { "Hello", "Visual Basic.NET" });
Make sure that you set the AutoCompleteMode to anything other then None. Play around with the 3 available options to get the feel that you feel best suits your application..If you have further questions please let us know.
Hi,
You can do this using the auto complete feature of a textbox, the drop down appears when the user types into the control. The textbox cannot be multiline though. If you set the textboxes auto complete mode to 'suggest' this will cause a drop down to appear. You need to also set the auto complete source, as an example set it to FileSystemDirectories, when you type in a file path the drop down appears.
Hi ashu_awasthi,
Try something like that.
namespace DataManage { public partial class Form5 : Form { public Form5() { InitializeComponent(); } DataTable dt = new DataTable(); private void Form5_Load(object sender, EventArgs e) { dt.Columns.Add("Id"); dt.Columns.Add("Name"); dt.Columns.Add("Descr"); dt.Rows.Add("001", "aaa", "aaaaaaaaa"); dt.Rows.Add("002", "bbb", "bbbbbbbbb"); dt.Rows.Add("003", "ccc", "ccccccccc"); dt.Rows.Add("004", "ddd", "ddddddddd"); this.listBox1.DisplayMember = "Name"; this.listBox1.ValueMember = "Name"; this.listBox1.DataSource = dt; this.listBox1.Visible = false; this.textBox2.Select(); } private void textBox1_Enter(object sender, EventArgs e) { this.listBox1.Visible = true; this.listBox1.BringToFront(); this.listBox1.Width = this.textBox1.Width; this.listBox1.Location = new System.Drawing.Point(this.textBox1.Location.X, this.textBox1.Location.Y + this.textBox1.Height); this.listBox1.SelectedIndexChanged += new EventHandler(listBox1_SelectedIndexChanged); } void listBox1_SelectedIndexChanged(object sender, EventArgs e) { this.textBox1.Text = this.listBox1.SelectedValue.ToString(); this.listBox1.Visible = false; this.listBox1.SelectedValueChanged -= new EventHandler(listBox1_SelectedIndexChanged); } private void textBox1_Leave(object sender, EventArgs e) { if (!this.listBox1.Focused) { this.listBox1.Visible = false; } this.listBox1.SelectedValueChanged -= new EventHandler(listBox1_SelectedIndexChanged); } } }
Hope this helps.
Regards