How to use checkbox in Delphi?

Now I have the code:

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

And then it continues with the rest of the code. Is this the right way to do this, or am I doing it wrong?

+3
source share
3 answers

What you offer is a perfectly legitimate way to determine if the checkbox is checked. The code that does this may look like

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

or how is it

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 received from the Checked property corresponds to the state of the flag at the moment you received the value.

+10
source
if DT.FieldByName('name_of_checkbox').AsBoolean=True then begin ..... end;
// In this case dt is TADOquery that you had used in your program.
0
source

2 if-statements, :

if odd(GetAsyncKeyState(VK_snapshot)) and CheckBox1.Checked then
begin
  ...
  ...
end;

if-statement (checkbox1.Checked) , True. ( Delphi )

-1

Source: https://habr.com/ru/post/1705006/


All Articles