开发者

How to populate a ToolStripComboBox?

开发者_如何学编程

I find it hard binding data to a ToolStripComboBox. It seems it doesn't have the ValueMember and DisplayMember properties.

How to bind it?


To access the wrapped combobox in toolstripcombobox and gain access to its ValueMember/DisplayMember/DataSource you have to write something like this:

ToolStripComboBox1.ComboBox.ValueMember = "YourValueField";


You shouldn't set ToolStripComboBox1.ComboBox.DataSource = null

If you set ToolStripComboBox1.ComboBox.DataSource = null then you can try

ToolStripComboBox1.ComboBox.DataSource = null
ToolStripComboBox1.ComboBox.DisplayMember= "DisplayName"
ToolStripComboBox1.ComboBox.ValueMember = "Value"
ToolStripComboBox1.ComboBox.DataSource = dataSource
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜