2013-04-08 63 views
0

我想在鼠標雙擊事件的ListView中添加ComboBox。在每次雙擊時,應在下一行添加一個新的ComboBox。如何在ListView中添加ComboBox在鼠標上雙擊事件

我嘗試了下面的代碼,但它不工作。

private void form_DblClick(object sender, form_DblClickEvent e) 
{ 
     ComboBox c; 
     this.Controls.Add(c = new ComboBox()); 
     c.Items.Add("Input"); 
     c.Items.Add("Delay"); 
     c.Items.Add("Message"); 
     c.Items.Add("comment"); 
     listView1.Controls.Add(c); 
} 

任何一個可以幫助我解決這個問題..

回答

0

您應該使用ComboboxItem

ComboBox c; 
ComboboxItem item = new ComboboxItem(); 
item.Text = "Input"; 
item.Value = value; 
c.Items.Add(item) 
ComboboxItem item1 = new ComboboxItem(); 
item1.Text = "Delay"; 
item1.Value = value; 
c.Items.Add(item1) 
//........ 
+0

沒有實際上我想補充ComboBox就都在一個組合框上面的元素..當我再次雙擊它..在下一行另一個組合框將添加所有元素.... – sanjeev 2013-04-08 08:23:52

相關問題