2016-05-27 14 views
0

私はDevExpress 15.2でgridLookUpEditを使用してデータを表示しています。私はすでに、この方法で複数の列で選択した値を表示することで問題を解決しました。DevExpress gridLookUpEditの複数の列のデフォルト値

private void gridLookUpEdit_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e) 
    { 
     GridLookUpEdit edit = sender as GridLookUpEdit; 
     int theIndex = edit.Properties.GetIndexByKeyValue(edit.EditValue); 
     if (edit.Properties.View.IsDataRow(theIndex)) 
     { 
      someObject row = (someObject)edit.Properties.View.GetRow(theIndex); 
      e.DisplayText = row.value1 + ": " + row.value2 + " " +row.value3; 
     } 
    } 

ご覧のとおり、3つの異なるセル値を使用してカスタム表示テキストを追加しています。私はデフォルト値に対して全く同じことをしたいと思います。ロード後、このパターンで最初に可能な行を表示したいと思います。 私は、このように最初の行を取得できることを、知っている:

gridLookUpEdit1.EditValue = gridLookUpEdit1.Properties.GetKeyValue(0); 

は、私はとにかく言及したイベントで呼び出す必要がありますか?それを解決する効率的な方法はありますか?

よろしくお願いいたします。

答えて

0

gridLookUpEdit.Properties.View dosen'tあなたはこれをチェックする2つのソリューション持っ 、負荷にデータソースを持っているので、負荷に表示されないカスタム表示テキスト:

1-このような選択デフォルト値の前にgridLookUpEdit.Properties.ViewにDataSourceをASSING:

gridLookUpEdit.Properties.View.GridControl.BindingContext = new BindingContext(); 
gridLookUpEdit.Properties.View.GridControl.DataSource = gridLookUpEdit.Properties.DataSource; 
gridLookUpEdit.EditValue = gridLookUpEdit.Properties.GetKeyValue(0); 

それとも

2 - あなたはこのようなCustomDisplayTextイベントにコードを変更することができます

private void gridLookUpEdit_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e) 
{ 
    GridLookUpEdit edit = sender as GridLookUpEdit; 
    int theIndex = edit.Properties.GetIndexByKeyValue(edit.EditValue); 
    if (theIndex >= 0) 
    { 
     DataRowView row = (DataRowView)edit.Properties.GetRowByKeyValue(edit.EditValue); 
     e.DisplayText = row[0].ToString() + ": " + row[1].ToString() + " " + row[2].ToString(); 
    } 
} 
+0

残念ながら、動作していません。値の代わりに「詳細を確認するために展開」というキャプションがあります。 – Bear

関連する問題