2014-12-02 34 views
0

我有一个devexpressgridcontrol。我想在网格的一列中使用:repositoryLookUpEdit。 我使用数据库问题填充repositoryLookUpEdit。 此问题返回三列:IdPerson,Name和IdCity。 Colums:IdPerson和Name有数据,但IdCity我必须在appication中设置。Devexpress RespositoryLookUp在网格中的值,价值便宜

所以 - 在gridcontrol中,Idcity列有fildename:IdCity和columnEdit:repositoryLookUpEdit。 - repositoryLookUpEdit具有DisplayValue:CityName和ValueMember:IdCity。

我的问题是:

当我在城市的一个行值格选择,我去到另一行,从第一行disaper值。

我在做什么错?你能给我一些建议吗?

我使用Devexpress 9.2。

this.gvPerson = new DevExpress.XtraGrid.Views.Grid.GridView(); 
this.replueCity = new DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit(); 
this.replueCity.Columns.AddRange(new DevExpress.XtraEditors.Controls.LookUpColumnInfo[] { new  DevExpress.XtraEditors.Controls.LookUpColumnInfo("IdCity", "IdCity", 20,  DevExpress.Utils.FormatType.None, "", false, DevExpress.Utils.HorzAlignment.Default), new DevExpress.XtraEditors.Controls.LookUpColumnInfo("CityName", "CityName")}); 
this.replueCity.DisplayMember = "CityName"; 
this.replueCity.Name = "replueCity"; 
this.replueCity.NullText = "[Choose city]"; 
this.replueCity.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard; 
this.replueOceny.ValueMember = "IdCity"; 
// CityColumn this.CityColumn.AppearanceCell.Options.UseTextOptions = true; 
this.CityColumn.AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; 
this.CityColumn.AppearanceCell.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center; 
this.CityColumn.Caption = "Ocena"; 
this.CityColumn.ColumnEdit = this.replueCity; 
this.CityColumn.FieldName = "IdCity"; 
this.CityColumn.Name = "IdCityName"; 
this.CityColumn.Visible = true; 
+0

在所有三种情况下检查字符串“IdCity”:它必须写得完全一样(请注意帽子!) – 2014-12-02 10:00:09

+0

我会检查,但它不起作用。 – Jola 2014-12-02 10:48:18

+0

然后粘贴一些代码... – 2014-12-02 11:04:56

回答

0

您必须设置为ValueMemberreplueCity(这是在列编辑器)。您只能为replueOceny设置它。

在所有三种情况下检查字符串IdCity:它必须写得完全一样(请注意帽子!)。

+0

我只为replueOceny设置ValueMember,但它仍然不起作用。当我从网格中的replookUpEdit中选择值时,然后转到下一行,第一行的值消失。 yhhh我做错了什么!!!! – Jola 2014-12-02 17:32:27

+0

谢谢大家给我建议。我解决了我的问题。因为我从DataBase的DataTable中填充了replueCity,并且我用同一数据库中的另一个DataTable填充了此网格,但我使用了不同的select。在网格中,DataTable不是用于填充replueCity的列。 – Jola 2014-12-04 09:33:55