【问题标题】:Repository item lookUpEdit resets after losing focus失去焦点后存储库项lookUpEdit重置
【发布时间】:2013-12-06 10:37:14
【问题描述】:

我有这个问题好几天了,找不到解决办法。我尝试了在互联网上找到的所有可能的解决方案,但似乎没有一个适合这个。 事情是我将存储库项添加到 gridControls (我通过设计器添加它,而不是通过代码)。然后,在代码中,我将数据源添加到该存储库lookUpEdit,并且我在该列的下拉菜单中有项目。但是当我在存储库中选择项目并单击其他单元格时,存储库中的选定项目被清除并且存储库再次显示空值... 任何想法我做错了什么?

编辑: 另外,当我单击网格中的任何单元格时,我会有一两秒的延迟,并且在延迟之后单击的单元格被聚焦...所有这些的任何解决方案?

编辑: 不知道要给你看什么代码,因为我都是在 devExpress 设计器中完成的。这是我将数据源设置为存储库项的代码的一部分,我将从该存储库项的设计器中为您提供代码。

private void ConfigureRepositoryItems()
    {
        BetService.SportManagerClient dbSportManager = new BetService.SportManagerClient();

        BetService.BLOddsControlSettings[] oddsControlSettings = dbSportManager.GetOddsControlSettings("", "");


        repositoryOddsControlSettings1.DataSource = oddsControlSettings;

    }

这是设计师的代码:

// 
        // repositoryOddsCalculationSettings1
        // 
        this.repositoryOddsCalculationSettings1.AutoHeight = false;
        this.repositoryOddsCalculationSettings1.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
        new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
        this.repositoryOddsCalculationSettings1.Columns.AddRange(new DevExpress.XtraEditors.Controls.LookUpColumnInfo[] {
        new DevExpress.XtraEditors.Controls.LookUpColumnInfo("ID", "ID", 20, DevExpress.Utils.FormatType.None, "", false, DevExpress.Utils.HorzAlignment.Default),
        new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Name", "Name")});
        this.repositoryOddsCalculationSettings1.DisplayMember = "Name";
        this.repositoryOddsCalculationSettings1.Name = "repositoryOddsCalculationSettings1";
        this.repositoryOddsCalculationSettings1.NullText = "Select Settings";
        this.repositoryOddsCalculationSettings1.PopupSizeable = false;
        this.repositoryOddsCalculationSettings1.ValueMember = "ID";

【问题讨论】:

  • LookUpEdit 分配到的字段的数据类型是什么?您是否设置了 GridColumn 的 FieldName 属性?
  • @Brandon - 我在我的 LookUpEdit 存储库中创建了 2 列。 “身份证”和“姓名”。 “名称”列显示字符串类型的数据。我的 gridControl 绑定到 dataSource,但我的列不是,所以在设计器中我将“fieldName”属性留空,并将“未绑定类型”属性设置为“String”。
  • 我遇到了类似的问题。原因是值成员错误(我使用“ID”而不是“Id”)。

标签: c# devexpress devexpress-windows-ui


【解决方案1】:

首先检查Grid 数据源中的列名和网格控件中的列是否匹配。匹配区分大小写,因此nameName 不相同,因此可能导致此问题。其次确保Grid 数据源列数据类型与LookUpEdit 的值类型匹配。如果LookupEdit 返回int 并且Grid 数据源列数据类型为string,仅此一项就可能引起很多麻烦。

【讨论】:

  • 我的是因为我使用的类是使用字段public int Number;而不是属性public int Number { get; set; }
猜你喜欢
  • 1970-01-01
  • 2011-06-30
  • 1970-01-01
  • 2016-03-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多