DevExpress ComboBoxEdit 实现 键值

 

http://www.wpf123.com/news/?143.html


定义 combox绑定类:

public class ComboxData

{

public string Text{ set; get; }

public string Value{ set; get; }

public override string ToString()

{

return Text;

}

}

具体绑定:

DevExpress.XtraEditors.ComboBoxEdit combox;

ComboxData data = new ComboxData();

data.Text ="需要显示的文本";

data.Value= “类似Tag功能”;

combox.Properties.Items.Add(data);

由于我们重写了ToString()方法,这样绑定后就可以显示我们重写内容里面的文本

使用:

string text=(combox.SelectedItem as ComboxData).Text;

string value=(combox.SelectedItem as ComboxData).Value;


posted @   星火燎猿*  阅读(44)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示