lookupedit按值设置选择
本文关键字:选择 设置 lookupedit | 更新日期: 2023-09-27 18:22:13
我有一个lookupedit,我需要通过单击按钮的事件来设置它的选择。但我做不到。
这就是我填充lookupedit 的方式
using (SqlConnection conn = new SqlConnection(GlobalParameters.logoSqlConnectionString))
{
conn.Open();
string selectSql = @"SELECT LOGICALREF,DEFINITION_ FROM [LG__CLCARD]";
DataTable dtDetail = GlobalParameters.getDataTable(selectSql, GlobalParameters.logoSqlConnectionString);
lookUpEditGeldigiFirma.Properties.DataSource= dtDetail;
lookUpEditGeldigiFirma.Properties.DisplayMember = "DEFINITION_";
lookUpEditGeldigiFirma.Properties.NullText = "Lütfen seçiniz.";
lookUpEditGeldigiFirma.Properties.ValueMember = "LOGICALREF";
}
我的lookupedit有三个元素,如下所示。
value:1 text:apple
value:2 text:orange
value:3 text:melon
我试着将选择设置为如下
// first attempt
lookUpEditGeldigiFirma.EditValue = "2";
// second attempt
lookUpEditGeldigiFirma.Properties.DisplayMember = "orange";
// third attempt
lookUpEditGeldigiFirma.Properties.ValueMember = "2";
这些尝试都无法在lookupedit中设置所选内容。请帮助我
您必须匹配类型。如果LOGICALREF
是类型int
,则您的呼叫为:
lookUpEditGeldigiFirma.EditValue = 2;