Ver Mensaje Individual
  #4  
Antiguo 05-12-2017
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Reputación: 11
aguml Va por buen camino
He estado probando con esto pero funciona regular y hace cosas raras como desaparecer el puntero en el form o que al poner una letra se autocompleta aunque la tengo esa opcion en false en el ComboBox1, o que al pulsar una letra primero va a una coincidencia en el combo y luego filtra:
Código PHP:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
TStringListMiLista;
unsigned int *valor,*aux;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponentOwner)
    : 
TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ComboBox1KeyUp(TObject *SenderWORD &Key,
      
TShiftState Shift)
{
    
int Index;

    
TStringListSalida = new TStringList();
    
int pos,contador=0;

    try{
        if(
ComboBox1->Text==""){
            
ComboBox1->Items->Assign(MiLista);
        }else{
            for(
int i=0;i<MiLista->Count;i++){
                
pos=UpperCase(MiLista->operator [](i)).Pos(UpperCase(ComboBox1->Text));
                if(
pos>0)
                {
                    
Salida->Add(MiLista->operator [](i));
                    
aux[contador]=valor[i];
                    
contador++;

                }
            }
            
ComboBox1->Items->Assign(Salida);
            
ComboBox1->SelStart ComboBox1->Text.Length();
            
ComboBox1->SelLength 0;
        }
        
        
ComboBox1->DroppedDown true;
    }
    
__finally
    
{
        
delete Salida;
    }
    
ComboBox2->Items->Clear(); //Este es para probar si funciona
    
for(int i=0;i<ComboBox1->Items->Count;i++)
        
ComboBox2->Items->Add(aux[i]);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
    
MiLista = new TStringList();
    
MiLista->Assign(ComboBox1->Items);

    
valor=new unsigned int[ComboBox1->Items->Count];
    for(
int i=0;i<ComboBox1->Items->Count;i++)
        
valor[i]=i;
    
aux=new unsigned int[ComboBox1->Items->Count];
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormClose(TObject *SenderTCloseAction &Action)
{
    
delete MiLista;
    
delete valor;
    
delete aux;
}
//--------------------------------------------------------------------------- 
A ver si podeis probarlo y me ayudais a dejarlo mejor y que sea mas agradable.
Responder Con Cita