开发者

dataGridView with comboBox

I have existing combo box in my program, it has adding some events, its list of element is changing in time. I have dataGridView with dataGridViewComboBoxColumn. Now I want to add my combo box to one cell in dataGridView. How can I make it? I try several examples, which I find in the Internet, but I doesn't work..

edit

I understand that it isn't possible. So, how can I add events to comboBox from dataGridViewComboBoxColumn?

edit 2

 dataGridView.EditingControlShowing += dataGridView1_EditingControlShowing;

 private void dataGridView1_EditingControlShowing (object sender, DataGridViewEditingControlShowingEventArgs e) {

    if ( e.Control is ComboBox) {
         ((ComboBox)e).event = new Handler;
    }
}
开发者_JS百科

It seems to work good, but example I can't join this comboBox with some tag.


I don't believe you can add just any combo box to a DataGridView, as they aren't the same type.

The DataGridViewComboBoxColumn type should automatically contain combo boxes of type DataGridViewComboBoxCell for you to use.

If you want several combo boxes to contain the same data, you should implement it in a way that they are all using the same data source.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜