mathes
asked on
Howto: Updating a TEdit component?
Hi experts,
I have a program with these components: 1 form, 1 Tedit and 3 TCheckboxes
I connected the three checkboxes with the figures "5" ,"3" and "7" .
Now I want to achieve that the Tedit displays the status (selected/not selected)
of the checkboxes.
For example if the checkbox with the "1" and the checkbox with the "3" are clicked",
the TEdit should display the figure "4", because 1+3 = 4.
The TEdit should be always updated, whenever I make a mouse-click on one of the 3
checkboxes.
Has anyone of you an idea, how this could be accomplished?
With kind regards
Mathes
I have a program with these components: 1 form, 1 Tedit and 3 TCheckboxes
I connected the three checkboxes with the figures "5" ,"3" and "7" .
Now I want to achieve that the Tedit displays the status (selected/not selected)
of the checkboxes.
For example if the checkbox with the "1" and the checkbox with the "3" are clicked",
the TEdit should display the figure "4", because 1+3 = 4.
The TEdit should be always updated, whenever I make a mouse-click on one of the 3
checkboxes.
Has anyone of you an idea, how this could be accomplished?
With kind regards
Mathes
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
set onClick event for all checkboxes to CheckBox1Clik1
{
CheckBox1.onClick = CheckBox1Click
CheckBox2.onClick = CheckBox1Click
CheckBox3.onClick = CheckBox1Click
}
procedure TForm1.CheckBox1Click(Send
var SUM : integer;
begin
SUM:=0;
if CheckBox1.Checked then SUM:=StrToInt(CheckBox1.Ca
if CheckBox2.Checked then SUM:=SUM+StrToInt(CheckBox
if CheckBox3.Checked then SUM:=SUM+StrToInt(CheckBox
Edit1.Text:=IntToStr(SUM);
end;
Cheers,
Igor.
PS: Captions (figures) on checkbox must be able to convert to numeric value.
Good morning, Meikl!
hi igor ;-)
where are you from?
hi mathes,
more independent, based on my first sample
const Multipler : Array[False..True] of Integer = (0,1);
//all checkboxes now on a panel for better iterating
//and the Checkbox-Caption holds the value, which should added
//this procedure is assigned to all checkbox.Onclick-event
procedure TForm1.CheckBox1Click(Send er: TObject);
var I,J : Integer;
begin
I := 0;
for j := 0 to panel1.ControlCount - 1 do
if (panel1.Controls[J] is TCheckBox) then
I := I + (StrToInt(TCheckBox(panel1 .Controls[ J]).Captio n) *
Multipler[TCheckBox(panel1 .Controls[ J]).Checke d]);
edit1.text := IntToStr(I);
end;
meikl
where are you from?
hi mathes,
more independent, based on my first sample
const Multipler : Array[False..True] of Integer = (0,1);
//all checkboxes now on a panel for better iterating
//and the Checkbox-Caption holds the value, which should added
//this procedure is assigned to all checkbox.Onclick-event
procedure TForm1.CheckBox1Click(Send
var I,J : Integer;
begin
I := 0;
for j := 0 to panel1.ControlCount - 1 do
if (panel1.Controls[J] is TCheckBox) then
I := I + (StrToInt(TCheckBox(panel1
Multipler[TCheckBox(panel1
edit1.text := IntToStr(I);
end;
meikl
Hi Meikl,
I'm from Almaty (GMT+6).
You can mail me igor@novell.kz
or call (7) 300-711-6527 (cell ;-)
I'm from Almaty (GMT+6).
You can mail me igor@novell.kz
or call (7) 300-711-6527 (cell ;-)
ASKER
Hi experts,
thank you for your help. This is exactly what I was looking for.
With kind regards
Mathes
thank you for your help. This is exactly what I was looking for.
With kind regards
Mathes
set onClick event for all checkboxes to CheckBox1Clik1
{
CheckBox1.onClick = CheckBox1Click
CheckBox2.onClick = CheckBox1Click
CheckBox3.onClick = CheckBox1Click
}
procedure TForm1.CheckBox1Click(Send
var SUM : integer;
begin
SUM:=0;
if CheckBox1.Checked then SUM:=StrToInt(CheckBox1.Ca
if CheckBox2.Checked then SUM:=SUM+StrToInt(CheckBox
if CheckBox3.Checked then SUM:=SUM+StrToInt(CheckBox
Edit1.Text:=IntToStr(SUM);
end;
Cheers,
Igor.
PS: Captions (figures) on checkbox must be able to convert to numeric value.