2016-12-09 1 views
1

フォーム上にtcxgridのすべての行をループしてその値を読み込む保存ボタンがあります。私はカラムの1つにあるコンボボックスの値を読み取ろうとしていますが、キー値はテキストではなく読み込む必要があります。cxGridをループするときに、TcxEditRepositoryComboBoxItemの選択項目にアクセスする方法?

for I := 0 to tv.DataController.RecordCount - 1 do 
begin 
    Location := tv.DataController.Values[I, colLocation.Index]; 
end; 

colLocationはコンボボックスですが、これを行うと、ItemIndex値ではなく選択されたテキストが表示されます。すべての手がかりは?

おかげ

+0

colLocation doItはアイテムプロパティを持っていません。コンボボックスはTcxEditRepositoryにあります。 –

答えて

2

あなたは現在のグリッド列のコンボボックスのItemsプロパティに数値インデックスを取得する方法を求めている場合はそれがない場合は、この

procedure TForm1.ProcessComboBox; 
var 
    I, 
    Index : Integer; 
    S : String; 
    V : OleVariant; 
begin 
    for I := 0 to tv.DataController.RecordCount - 1 do 
    begin 
    V := tv.DataController.Values[I, colLocation.Index]; 
    S := V; 
    // if the RepositoryItem of colLocation is set to cxEditRepository1ComboBoxItem1 
    // you can do 
    Index := cxEditRepository1ComboBoxItem1.Properties.Items.IndexOf(S); 

    // OR, if the Properties property of colLocation is set to ComboBox you could do 
    // Index := TcxComboBoxProperties(colLocation.Properties).Items.IndexOf(S); 

    S := IntToStr(Index); 
    Caption := S; 
    end; 
end; 

のようなコードでそれを行うことができますあなたのqに答えると、正確にあなたが何をdoしたいかを説明する方が良いでしょう。

+0

ニース!、それが動作します。私はcxEditRepositoryComboBoxItemを持っています。 –

関連する問題