简体   繁体   English

Winforms组合框和数据绑定

[英]Winforms Combobox and Databinding

I am databinding a combobox to a DataSet, however I want to insert a single item at the top for "None". 我将组合框数据绑定到DataSet,但是我想在顶部插入单个项目“None”。

Doing: 这样做:

 combobox.Items.Insert(0,"None");

Doesn't work, as the combobox is now expecting a DataRowView, however DataRowView doesn't have a public constructor, so I can't fake it that way. 不起作用,因为组合框现在期待DataRowView,但DataRowView没有公共构造函数,所以我不能这样伪装它。

Any advice? 有什么建议? I'm sure this is a well solved problem. 我确信这是一个很好解决的问题。

Insert to the object you are databinding to rather than to the combobox. 插入要数据绑定的对象而不是组合框。 Good example below. 下面的好例子。

http://social.msdn.microsoft.com/forums/en-US/winforms/thread/70785e67-5c27-428f-ac79-e45c8c70c3e8/ http://social.msdn.microsoft.com/forums/en-US/winforms/thread/70785e67-5c27-428f-ac79-e45c8c70c3e8/

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

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