lookupedit按值设置选择

时间:2013-07-12 19:46:04

标签: c# winforms devexpress repositorylookupedit

我有一个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有3个元素如下。

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中设置选择。请帮帮我

1 个答案:

答案 0 :(得分:2)

您必须匹配该类型。如果LOGICALREF类型为int,则表示您的电话号码为:

lookUpEditGeldigiFirma.EditValue = 2;