How to Update data by Using TEdit?


2004-09-17 10:12:44 PM
cppbuilder21
Hi everybody,
I would like to know how to Update the data by Using TEdit components.
What Event I should have to deal with in addition to the OnKeyPress
evetn whcih i have to deal to define the type of data i should add up
as shown i nthis example:
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
// This is the way to ensure that the number iside will be on
the right
DecimalSeparator = '.';
long style1 = GetWindowLong(Edit1->Handle, GWL_STYLE);
SetWindowLong(Edit1->Handle, GWL_STYLE, style1 | ES_RIGHT);
// This is the way to ensure thqat the data will appear as
right justify
FMaxChars = 6; // Charactor Limitation
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Edit1KeyPress(TObject *Sender, char &Key)
{
// Set Key Press NO Negative Value Allowed!
if(!isdigit(Key) && (Key != VK_ESCAPE) && (Key != VK_BACK) &&
(Key != DecimalSeparator ||
Edit1->Text.Pos(DecimalSeparator) !=0))
Key = 0;
if (Key == VK_RETURN)
{
// Input(Key);
}
else
{
if (RestartInput)
{
Edit1->Text =
FloatToStrF(TopMarginOld,ffGeneral,2,FMaxChars);
RestartInput = false;
}
if (Key == 8)
{ //backspace
Edit1->Text.Delete(Edit1->Text.Length(),FMaxChars);
Invalidate();
}
else if (Edit1->Text.Length()>FMaxChars);
else
{
Edit1->Text += Key;
Invalidate();
}
}
}