Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wix CheckBox default state

The dialog below displays a checkbox which on selected enables the Next Button. The problem is I cant get the initial state of it to be set to unchecked when the form first appears. I have tried setting the CheckBoxValue = 1 but that doesnt either work.

    <Dialog Id="DatabaseDialog" X="50" Y="50" Width="373" Height="287" Title="[ProductName]">
                <Control Id="EnableCheckBox" Property="DatabaseBackedUp" Type="CheckBox" X="20" Y="150" Width="290" Height="30" 
                         Text="Has the database been backed up?" CheckBoxValue="0" />
                <Control Id="NextButton" Type="PushButton" X="300" Y="261" Width="66" Height="18" Text="{\VSI_MS_Sans_Serif13.0_0_0}&amp;Next &gt;" TabSkip="no" Default="yes">
                    <Publish Event="EndDialog" Value="Return">DatabaseDialog_NextArgs=""</Publish>
                    <Publish Event="NewDialog" Value="[DatabaseDialog_NextArgs]">DatabaseDialog_NextArgs&lt;&gt;""</Publish>
                 <Condition Action="disable"><![CDATA[DatabaseBackedUp<> "1"]]></Condition>
                 <Condition Action="enable"><![CDATA[DatabaseBackedUp= "1"]></Condition>
                </Control>
</Dialog>
like image 748
Jonathan Avatar asked Oct 24 '12 09:10

Jonathan


2 Answers

This is the way I do it and it works for me

The Property:

  <Property Id="CHECKBOX" Secure="yes"></Property>

The checkbox:

<Control Id="CheckBoxId" Type="CheckBox"  Text="Use the proxy server for your LAN" Property="CHECKBOX" Width="180" Height="15" X="25" Y="103" CheckBoxValue="1"/>

I believe this works because you are firstly setting the property linked to the checkbox to nothing so it stays empty and if it is clicked then the property value is equal to whatever the CheckBoxValue is set to. (That's my logic anyway..:)) Hope this helps

like image 170
Natalie Carr Avatar answered Oct 12 '22 10:10

Natalie Carr


You have defined a control:

<Control Id="EnableCheckBox"
         Type="CheckBox"
         Property="DatabaseBackedUp" 
         X="20" Y="150" Width="290" Height="30" 
         Text="Has the database been backed up?" 
         CheckBoxValue="0" />

You don't mention whether you have also defined a DatabaseBackedUp property elsewhere in your solution, but I assume that you have defined something like this:

<Property Id="DatabaseBackedUp" Value="0"></Property>

You may have tried other values for Value. However, I believe the checkbox will interpret the existence of any value as meaning "I should be checked".

However, if you do not set a Value attribute then you will get a warning: "Property 'CHECKBOX' does not contain a Value attribute and is not marked as Admin, Secure, or Hidden. The Property element is being ignored."

Setting one of these attributes will make the warning go away, but will come with additional behaviour that may or may not be desired.

The solution is simply to delete the property.

The checkbox will then find no value for it and will default to unchecked. Checking it will still work as desired (i.e. it will create and set a value for the property).

I have tried this successfully with WiX v3.11.1.

like image 43
Ben L Avatar answered Oct 12 '22 08:10

Ben L