1 (edited by tcoton 2014-12-09 13:47:32)

Topic: Using Checkbox

Hi,

I would like to use a chekbox to assign a specific value in a column for the current shown record only, how to implement that?

There is no easy function associated to checkbox as it is for textbox. wink

What I would like to do for instance is: when the checkbox is ticked, it updates a value in a column. (ex: if checkbox = true then update column 'a' with value "xyz")

Any idea?

Re: Using Checkbox

Hello,


How it should look?
Can you make test project for me, and I will try to develop it on your example.

Dmitry.

Re: Using Checkbox

I will send you my current project with explaination. I have anonymized the data in the db wink

Re: Using Checkbox

Thanks a lot for your help,

for the sake of other people willing in reproducing this item, please find below the working code:

//##################################################################################################
// Field protection and Checkbox section

// Checkbox to add "DECT" in two fields at once EditCisco Form
procedure AddInfo_CheckBox1_OnMouseUp (Sender: string; MouseLeft, MouseRight, MouseMiddle: boolean; Shift, Alt, Ctrl: boolean; X, Y: Integer);
begin
    if AddInfo.CheckBox1.Checked then
    begin
        if not AddInfo.AddTK.ReadOnly then
        begin
            AddInfo.AddTK.Text:='DECT';
            AddInfo.AddPF.Text :='DECT';
        end;
    end;
end;


// Check if fields PF is empty or not for the checkbox, if not empty then read-only AddInfo Form
procedure AddInfo_AddPF_OnChange (Sender: string);
begin
    if (AddInfo.AddTK.Text='DECT') and (AddInfo.AddPF.Text='DECT') then AddInfo.CheckBox1.Checked:=True else AddInfo.CheckBox1.Checked:=False;
end;


// Check if fields TK is empty or not for the checkbox, if not empty then read-only AddInfo Form
procedure AddInfo_AddTK_OnChange (Sender: string);
begin
    if (AddInfo.AddTK.Text='DECT') and (AddInfo.AddPF.Text='DECT') then AddInfo.CheckBox1.Checked:=True else AddInfo.CheckBox1.Checked:=False;
end;


// Protect fields PF and TK when not empty, if not empty then read-only AddInfo Form
procedure AddInfo_OnShow (Sender: string; Action: string);
begin
    if AddInfo.AddPos.Text<>'' then AddInfo.AddPos.ReadOnly := True else AddInfo.AddPos.ReadOnly := False;
    if AddInfo.AddTK.Text<>'' then AddInfo.AddTK.ReadOnly := True else AddInfo.AddTK.ReadOnly := False;
    sLastActionForm := Action; // variable for edit/add logging
end;

Re: Using Checkbox

I would need some help with another use of the checkbox component:

I have a field with a default value= "NO"

If I check the checkbox, I would like this value to be updated to "YES", is that possible or should I use a dropdown list?

Re: Using Checkbox

tcoton wrote:

I would need some help with another use of the checkbox component:

I have a field with a default value= "NO"

If I check the checkbox, I would like this value to be updated to "YES", is that possible or should I use a dropdown list?


Please, use default value 0 - for NO
and 1- for YES


Maybe I misunderstand the question.
This is exactly as it should work, you have not?

Dmitry.

Re: Using Checkbox

0 & 1 are working fine, that's right. But I would like to see words instead of 0 or 1 if I request this information.


For example, I would like to display "No" instead of "0" and "Yes" instead of "1". Using checkboxes this way may give more sense.

It is actually translating a value by a more readable one for the users.

How would you do that?

Re: Using Checkbox

Exactly where you want to see Yes/No and how?
Can you show me a screenshot?


Thanks.

Dmitry.

Re: Using Checkbox

I would like to see the translated data in the grid. I cannot add a picture in this forum as there is no "download picture" choice.

for example:


I want to return the following information in a grid with a default query using no filter nor script:


PC Name  |  Installation Date   |  Config Record created

L2006       |   24.01.2014          |    Yes
L2007       |   24.01.2015          |    No



What I get currently is:

PC Name  |  Installation Date   |  Config Record created

L2006       |   24.01.2014          |    1
L2007       |   24.01.2015          |    0

Re: Using Checkbox

By default (if you don't use SQL query), it should work the way you want (with Yes/No instead of 1/0)


Please, send me your project to support@drive-software.com

Dmitry.

Re: Using Checkbox

Actually there is no way to tell the checkbox which value to display!
I will send you the project, it is still in draft.


Oh! I can see the attachments option now! smile

Re: Using Checkbox

You have mixed types of field TEXT and BOOLEAN
I sent to you fixed project.

Dmitry.

Re: Using Checkbox

That's great, thanks a lot!

Re: Using Checkbox

hello Dmitry
can you please send me an example how to use checkbox.
please a simple file, with 3 choices as checkbox
thanks

Re: Using Checkbox

chiklopes
Hello,


You need an example, where you can select a one value of the three checkbox? Like in ComboBox?

Dmitry.

Re: Using Checkbox

Dmitry
Hello,
no, sorry to respond so late!
what I want is simple:

first example
as object "colors"
multiple choice: red, yellow, green, blue
I can choose:
1- just "red"
2- red, yellow, green
3-red, blue
4-or all colors

second example:
I can choose just one, from the four choices
thks

Re: Using Checkbox

chiklopes

I made a example for you

Post's attachments

Attachment icon CheckBoxes.zip 4.46 kb, 712 downloads since 2015-02-11 

Dmitry.

Re: Using Checkbox

thanks a lot Dmitry
it work