| Ver tema anterior :: Ver tema siguiente |
| Autor |
Mensaje |
vizca321 Lt


Registrado: 06 May 2008Mensajes: 83Ubicación: Mexico
|
Publicado: Jue 06 Abr, 2023 11:12 pm Asunto: Borrar Items Duplicados ComboBox o ListBox |
|
|
No puedo evitar items duplicados en combobox tengo este codigo
| Código: | for(int i = 0; i < FInsumos->CBCategoria->Items->Count;i++){
for(int j = 1; j < FInsumos->CBCategoria->Items->Count-1;j++){
if(FInsumos->CBCategoria->Items->Strings[i] == FInsumos->CBCategoria->Items->Strings[j]){
FInsumos->CBCategoria->Items->Delete(j);
}
}
} |
Y encontre este para Delphi pero no puedo implementarlo en c++builder
| Código: | var
SL: TStringList;
begin
SL := TStringList.Create;
try
SL.Sorted := True; // Required for Duplicates to work
SL.Duplicates := dupIgnore;
SL.AddStrings(ComboBox1.Items);
ComboBox1.Items.Assign(SL);
finally
SL.Free;
end;
end; |
|
|
| Volver arriba |
|
 |
escafandra Master

Registrado: 29 Nov 2007Mensajes: 625Ubicación: Madrid - España
|
Publicado: Dom 09 Abr, 2023 1:17 pm Asunto: |
|
|
Prueba así:
| Código: |
TStringList *SL = new TStringList;
SL->Sorted = True; // Required for Duplicates to work
SL->Duplicates = dupIgnore;
SL->AddStrings(ComboBox1->Items);
ComboBox1->Items->Assign(SL);
delete SL;
|
Saludos |
|
| Volver arriba |
|
 |
vizca321 Lt


Registrado: 06 May 2008Mensajes: 83Ubicación: Mexico
|
Publicado: Mie 12 Abr, 2023 3:10 am Asunto: |
|
|
Me regresa el siguiente error el compilador es Alexandria no se si tiene algo que ver
| Código: | [bcc32c Error] Unit1.cpp(23): reference to 'dupIgnore' is ambiguous
System.Types.hpp(55): candidate found by name lookup is 'System::Types::TDuplicates::dupIgnore'
System.Classes.hpp(4651): candidate found by name lookup is 'System::Classes::dupIgnore' |
_________________ [code:1]//----------------Att Gabriel----------------
void Gracias(){
if (Respuesta == true){
Showmessage("Muchisimas Gracias!")
else
Showmessage("Ojala te sirva... ^_^ ");
}[/code:1] |
|
| Volver arriba |
|
 |
escafandra Master

Registrado: 29 Nov 2007Mensajes: 625Ubicación: Madrid - España
|
Publicado: Jue 13 Abr, 2023 6:18 pm Asunto: |
|
|
Prueba así:
| Código: |
TStringList *SL = new TStringList;
SL->Sorted = True; // Required for Duplicates to work
SL->Duplicates = Classes::dupIgnore;
SL->AddStrings(ComboBox1->Items);
ComboBox1->Items->Assign(SL);
delete SL;
|
Saludos |
|
| Volver arriba |
|
 |
vizca321 Lt


Registrado: 06 May 2008Mensajes: 83Ubicación: Mexico
|
Publicado: Vie 14 Abr, 2023 7:43 am Asunto: |
|
|
Excelente funciona perfecto Gracias Escafandra _________________ [code:1]//----------------Att Gabriel----------------
void Gracias(){
if (Respuesta == true){
Showmessage("Muchisimas Gracias!")
else
Showmessage("Ojala te sirva... ^_^ ");
}[/code:1] |
|
| Volver arriba |
|
 |
|