//-------------UNIT1.CPP-----------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Table1->Open();
Table1->First();
while (!Table1->Eof)
{
cb->Items->Add(Table1->FieldByName("Dato")->AsString);
Table1->Next();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::cbKeyPress(TObject *Sender, char &Key)
{
lastkey = Key;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::cbChange(TObject *Sender)
{
String srch = cb->Text;
if ((lastkey == 0x08) || (lastkey == VK_DELETE))
{
lastkey = 0;
return;
}
lastkey = 0;
int ix = cb->Perform(CB_FINDSTRING,-1,(LPARAM)srch.c_str());
if (ix != CB_ERR)
{
cb->ItemIndex = ix;
cb->SelStart = srch.Length();
cb->SelLength = (cb->Text.Length()-srch.Length());
}
}
//---------------------------------------------------------------------------