winform girdlookupedit

本文介绍如何使用C#代码配置GridLookUpEdit控件,包括设置列显示名称、绑定字段名、选择项显示及值、绑定数据源及默认文本,并提供获取选中项值的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//代码改变列,Caption为下拉框列显示名称,fieldName对应绑定数据得列名

        this.gridLookUpEdit1.Properties.View.Columns[0].Caption = "拼音";
        this.gridLookUpEdit1.Properties.View.Columns[1].Caption = "备注";
        this.gridLookUpEdit1.Properties.View.Columns[2].Caption = "代码";

        this.gridLookUpEdit1.Properties.View.Columns[0].FieldName = "Py";
        this.gridLookUpEdit1.Properties.View.Columns[1].FieldName = "Deptname";
        this.gridLookUpEdit1.Properties.View.Columns[2].FieldName = "Deptid";
        
        //ValueMember  相当于editvalue  
        //DisplayMember 为选中项显示得值,ValueMember 为获取到的值
		this.gridLookUpEdit1.Properties.ValueMember = "Deptid";   
        this.gridLookUpEdit1.Properties.DisplayMember = "Deptname";    //相当于text  
        //绑定list集合
        this.gridLookUpEdit1.Properties.DataSource = deptlist;
		//默认为请选择
        this.gridLookUpEdit1.Properties.NullText = "请选择";
		
		//获取选中项得值
	   string deptid = this.gridLookUpEdit1.EditValue.ToString();
	   ![显示效果](https://img-blog.csdnimg.cn/91312a7f26d747b8b0e812edfe75b15f.png)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值