sirdank
sirdank

Reputation: 3571

Check checkbox when another checkbox is checked

Here is my WIX:

<Control Id="FeatureOneBox" Type="CheckBox" Property="FEATUREONE" Text="Feature One" X="30" Y="87" Height="10" Width="200" CheckBoxValue="1" />
<Control Id="FeatureTwoBox" Type="CheckBox" Property="FEATURETWO" Text="Feature Two" X="30" Y="107" Height="10" Width="200" CheckBoxValue="1" />
<Control Id="FeatureThreeBox" Type="CheckBox" Property="FEATURETHREE" Text="Feature Three" X="30" Y="107" Height="10" Width="200" CheckBoxValue="1" />
<Control Id="CoreFeatureBox" Type="CheckBox" Property="INSTALLCORE" Text="!(loc.CoreFeatureBox)" X="30" Y="147" Height="10" Width="300" CheckBoxValue="1">
    <Condition Action="enable"><![CDATA[FEATURETWO <> 1 AND FEATURETHREE <> 1]]></Condition>
    <Condition Action="disable">FEATURETWO = 1 OR FEATURETHREE = 1</Condition>
</Control>

I want to require the Core feature if either feature two or three is selected. I can do this by altering the feature condition but, it the user unchecks both of those, unchecks Core, then rechecks one of those, I don't want to install the Core feature even though its checkbox is unchecked.

How can I check CoreFeatureBox at the same time I disable it?

Upvotes: 1

Views: 408

Answers (1)

sirdank
sirdank

Reputation: 3571

If only I'd googled just a few minutes more!

This code is all I needed:

<Control 
   Id="CB1" 
   Type="CheckBox" 
   Property="myCheckboxResult" 
   CheckBoxValue="my value" 
   Text="Check the box please." 
   X="50" 
   Y="50" 
   Height="10" 
   Width="150">

   <Publish Property="myCheckboxResult2" Value="my value" Order="1">myCheckboxResult</Publish>
   <Publish Property="myCheckboxResult2" Value="{}" Order="2">NOT myCheckboxResult</Publish>
   </Control>

<Control 
   Property="myCheckboxResult2" 
   Id="CB2" 
   Type="CheckBox" 
   CheckBoxValue="my value" 
   Text="Check the box please." 
   X="50" 
   Y="70" 
   Height="10" 
   Width="150" />

I added the <Publish/> nodes under FeatureTwoBox and FeatureThreeBox and everything's working.

Upvotes: 1

Related Questions