如何从对应的编辑值中获取devexpress的lookupedit显示文本

发布于 2024-09-24 03:15:10 字数 692 浏览 2 评论 0原文

大家好,

我想在给出相应的编辑值时获得查找编辑显示文本。

例子: 如果我给出

LookupEdit1.Editvalue="3";

,那么它应该显示 Editvalue="3" 的显示文本,

请帮忙

//code

 cmbChemical.Properties.DataSource = _lab.selectChemicals();
        cmbChemical.Properties.DisplayMember = "labitem_Name";
        cmbChemical.Properties.ValueMember = "labItem_ID";
        cmbChemical.Properties.BestFitMode = BestFitMode.BestFit;
        cmbChemical.Properties.SearchMode = SearchMode.AutoComplete;

        cmbChemical.Properties.Columns.Add(new LookUpColumnInfo("labitem_Name", 100,  "Chemicals"));
    cmbChemical.Properties.AutoSearchColumnIndex = 1;

Hai all,

I want to get lookupedit display text when am giving correspond edit value.

example:
if am giving

LookupEdit1.Editvalue="3";

then it should show display text of Editvalue="3"

please help

//code

 cmbChemical.Properties.DataSource = _lab.selectChemicals();
        cmbChemical.Properties.DisplayMember = "labitem_Name";
        cmbChemical.Properties.ValueMember = "labItem_ID";
        cmbChemical.Properties.BestFitMode = BestFitMode.BestFit;
        cmbChemical.Properties.SearchMode = SearchMode.AutoComplete;

        cmbChemical.Properties.Columns.Add(new LookUpColumnInfo("labitem_Name", 100,  "Chemicals"));
    cmbChemical.Properties.AutoSearchColumnIndex = 1;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

天涯离梦残月幽梦 2024-10-01 03:15:10

你不能,至少不能以你正在尝试的方式。顾名思义,LookUpEditDataSource 中查找其值,例如。对象的集合。因此,要显示值3,您需要有一个包含该值的对象列表,并将其设置为控件的DataSource

List<string> values = new List<string>();
values.Add("3");
lookUpEdit.Properties.DataSource = values;
lookUpEdit.EditValue = "3";

也许如果您指定您想要做什么,我们可以帮助您实现这一目标。

You can't, at least not in the way you're trying. The LookUpEdit, as the name implies, looks up its values in a DataSource, eg. a collection of objects. Therefore, to display the value 3 you need to have a list of objects that contains this value and set it as a DataSource for the control.

List<string> values = new List<string>();
values.Add("3");
lookUpEdit.Properties.DataSource = values;
lookUpEdit.EditValue = "3";

Maybe if you specify what are you trying to do, we can help you achieve that.

南街女流氓 2024-10-01 03:15:10

我认为您不必指定显示成员或值成员即可获得所需的行为。以下代码为我提供了一个表单,其中查找编辑正确显示“4”,我也可以从列表中选择其他值。

using System.Collections.Generic;
using System.Windows.Forms;
using DevExpress.XtraEditors;

public class Form1 : Form
{
    public Form1()
    {

        var lookUpEdit1 = new LookUpEdit();
        Controls.Add(lookUpEdit1);

        var source = new List<string>();
        for (var i = 0; i < 10;i++ )
            source.Add(i.ToString());
        lookUpEdit1.Properties.DataSource = source;
        lookUpEdit1.EditValue = "4";
    }

}

也许您会得到错误的结果,因为您设置了控件的显示成员和值成员。

I think you don't have to specify display member or value member to get your needed behaviour. Following code give me a form with the lookupedit correctly showing "4", and i can choose other values from the list too.

using System.Collections.Generic;
using System.Windows.Forms;
using DevExpress.XtraEditors;

public class Form1 : Form
{
    public Form1()
    {

        var lookUpEdit1 = new LookUpEdit();
        Controls.Add(lookUpEdit1);

        var source = new List<string>();
        for (var i = 0; i < 10;i++ )
            source.Add(i.ToString());
        lookUpEdit1.Properties.DataSource = source;
        lookUpEdit1.EditValue = "4";
    }

}

Maybe you get wrong results because you set display member and value member of the control.

多彩岁月 2024-10-01 03:15:10

这段代码对我有用。

private void lookUpEdit1_KeyUp(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Enter)
    {
        MessageBox.Show((e.OriginalSource as SLTextBox).Text);
    }
}

This code worked for me.

private void lookUpEdit1_KeyUp(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Enter)
    {
        MessageBox.Show((e.OriginalSource as SLTextBox).Text);
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文