2017-05-15 22 views
1

인터넷에서 XML 파일을받습니다 (XML의 값은 통화가 다를 수 있으므로 달라질 수 있음). 그런 다음 목록 상자 1에로드합니다. 사용자는 일부 단추 (하나씩, 모두, 삭제 등)로 목록 상자 2에 항목을 추가 할 수 있습니다. 그래서 나는 중복을 막고 싶다. 나는 이것을 할 어떤 방법을 찾을 수 없습니다.Inno Setup의 목록 상자 및 콤보 상자에서 중복 항목을 방지 하시겠습니까?

내 목록 상자 :

enter image description here

가 여기 내 코드입니다 (XML 파싱 부분, How to read multiple XML nodes? (Inno Setup) 참조)

XMLNodeList := XMLDocument.SelectNodes('//listaPaises/item'); 
for Index := 0 to XMLNodeList.length - 1 do 
begin 
    XMLNode := XMLNodeList.item[Index]; 

    { Add country } 
    comboBoxPais.Items.Add(XMLNode.SelectSingleNode('name').Text); 

    { Add currency } 
    listBoxMonedasDisponibles.Items.Add(XMLNode.SelectSingleNode('suggestedCurrency').Text); 

    listBoxMonedasDisponibles.ItemIndex := 0; 
    comboBoxPais.ItemIndex := 0; 
end; 

답변

1
모두 TComboBox.Items

TListBox.Items 유형 TStrings의이다.

주어진 문자열이 이미 존재하는지 테스트하려면 TStrings.IndexOf을 사용하십시오. 문자열이 없으면 음수 (-1)를 반환합니다.

{ Add S only, if not present already } 
if comboBox.Items.IndexOf(S) < 0 then 
    comboBox.Items.Add(S);