Jump to content
Lainkes

DBCheckbox uncheck all

Recommended Posts

Hello,

 

I linked some DBCheckboxes to my database.

But when I create a new record, all the DBCheckboxes are filled with black. 

Even if the default value is set on False in the DB. (Using mariiaDB in HeidISQL).

So I was wondering how I can uncheck all these DBCheckbox components.

I used this code, but it's stays black.

            // reset all DBCheckboxes
            for t := 0 to ComponentCount - 1 do
              if Components[t] is TDBCheckBox then
                begin
                  // showmessage(Components[t].Name + ' ' + intToStr(t));
                  (Components[t] As TDBCheckBox).Checked := False;
                end;

When I do a showmessage, the correct names of the components are shown.

 

Thanks for your feedback

 

Alain

Share this post


Link to post

As long as you don't change it, any field in  a new record is initialized with Null. A TDBCheckBox displays a NULL as grayed - that is what you see.

 

The easiest way to avoid this is to wire the OnNewRecord event of the dataset and initialize the relevant fields with False.

Share this post


Link to post
Posted (edited)

Thanks for your feedback.

 

Greetings

 

Alain

Edited by Lainkes

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×