简体   繁体   English

如何在C#Combobox中添加动态文本框

[英]How to add dynamic textbox in C# Combobox

I want to add "other" option in my combobox lists, and when we selected it then dynamically a text box should appear and asks for other value like other talent things. 我想在我的组合框列表中添加“其他”选项,当我们选择它时,动态地会出现一个文本框,并像其他人才一样要求其他值。

Thanks in advance, Vengadesh 在此先感谢,Vengadesh

You may need code like following :) 您可能需要以下代码:)

private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
{
    if (this.comboBox.Text.Equals("Other"))
        this.yourTextBox.Visible = true;
    else 
        this.yourTextBox.Visible = false;
}

Try it, 试试吧,

there is no way to add TextBox in a ComboBox. 没有办法在ComboBox中添加TextBox。 instead of that we can add items in the combobox. 而不是我们可以在组合框中添加项目。

here the combobox is the object of ComboBox class 这里的组合框是ComboBox类的对象

combobox.Items.Add(new ComboBoxItem()
                   {
                    Text="Other"
                   });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM