-2
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
ComboBox item = new ComboBox();
item.Name = "subCat";
item.Location = new System.Drawing.Point(100, 71);
item.Width = 200;
item.Height = 21;
item.Text = "Choose SubCategori";
item.Items.Add("test1");
this.Controls.Add(item);
}
現在我需要創建combobox_value_changed事件。如何用c#代碼創建新的組合框?
請幫幫我。 (對不起英文)
可以正常訪問。例如,如果你想讓這個確切的方法處理'item.SelectedIndexChanged',你所要做的就是'item.SelectedIndexChanged + = comboBox1_SelectedIndexChanged;' – AntiTcb
如果這是ASP.NET,則像這樣創建的控件將會是頁面發佈到服務器時丟失。 – niksofteng