Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a checkbox in Delphi?

Right now, I have the code:

begin
If odd(GetAsyncKeyState(VK_snapshot)) then
If CheckBox1.Checked then
begin

And then it continues on with the rest of the code. Is that the correct way of doing that, or am I doing it wrong?

like image 505
PuppyKevin Avatar asked Dec 30 '22 03:12

PuppyKevin


1 Answers

What you suggest is a perfectly legal way to determine if a checkbox is checked. The code doing so might look like

if checkBox.Checked then begin
    //do whatever needed for checked checkbox
end

or like this

if checkBox.Checked then begin
    //do whatever needed for checked checkbox
end else begin
    //do whatever needed for unchecked checkbox
end

Just remember that the value you obtained from Checked property corresponds to the checkbox's state at the moment when you obtained the value.

like image 51
sharptooth Avatar answered Jan 01 '23 18:01

sharptooth