2017-01-21 7 views
2

フォーム上では、スキンをdxBarCombo1に追加しています。dxBarCombo1でスキン名が重複しないようにする

for I := 0 to cxLookAndFeelPaintersmanager.Count -1 do 
    begin 
    if (cxLookAndFeelPaintersmanager.Items[i].lookandfeelname <> 'UltraFlat') 
    and (cxLookAndFeelPaintersmanager.Items[i].lookandfeelname <> 'Flat') 
    and (cxLookAndFeelPaintersmanager.Items[i].lookandfeelname <> 'Standard') 
    and (cxLookAndFeelPaintersmanager.Items[i].lookandfeelname <> 'Native') 
    and (cxLookAndFeelPaintersmanager.Items[i].lookandfeelname <> 'Office11') 
    then begin 
    dxBarCombo1.Items.Add(cxLookAndFeelPaintersmanager.Items[i].lookandfeelname) ; 
    (cxBarEditItem2.Properties as TcxComboBoxProperties).Items.Add(cxLookAndFeelPaintersmanager.Items[i].lookandfeelname); 
    end; 

メインフォームを非表示にして表示すると、同じスキンを繰り返し追加し続けるので、コンボで重複して表示されます。

これらのスキンが常に追加されないように、私は何を書く必要がありますか?

私はコンボをクリアするために近い形にしようとした:

dxBarCombo1.Items.Clear; 

動作するようには思えません。

煩わしい。

+0

OT:**一時変数を使用してください。 –

答えて

4

皮膚名がコンボボックスに既に存在するかどうかをチェックすることができます:

if (cxBarEditItem2.Properties as TcxComboBoxProperties).Items.IndexOf(
      cxLookAndFeelPaintersmanager.Items[i].lookandfeelname) = -1 then 
    (cxBarEditItem2.Properties as TcxComboBoxProperties).Items.Add(
        cxLookAndFeelPaintersmanager.Items[i].lookandfeelname) 
+0

ありがとう – user3351050

関連する問題