Is it possible to hide textboxes on checkbox checked in WiX?
Asked
Active
Viewed 6,298 times
10
-
1I don't really understand what you need, but you can hide and show controls dynamically by using control conditions: http://wix.sourceforge.net/manual-wix2/wix_xsd_condition.htm – Cosmin Mar 31 '11 at 14:33
-
1Seems to be a special case of this one: http://stackoverflow.com/questions/4241863/wix-interactions-with-conditions-properties-custom-actions – Yan Sklyarenko Mar 31 '11 at 15:48
2 Answers
15
Thanks for your comments, the first comment helped me. It is done like this:
<Control Id="LoginTextBox" Type="Edit" Text="CM2" Height="17" Width="200" X="150" Y="198" Property="Login">
<Condition Action="hide" >CreateDBUsers<>1</Condition>
<Condition Action="show" >CreateDBUsers=1</Condition>
</Control>

G S
- 35,511
- 22
- 84
- 118

Bogdan Verbenets
- 25,686
- 13
- 66
- 119
-
1But note that it won't happen dynamically. I mean, if you change the checkbox state, the edit boxes on the same dialog won't hide, even if the condition is appropriate, until you refresh the dialog (next/back) – Yan Sklyarenko Apr 01 '11 at 11:56
-
@Yan Sklyarenko: It won't? I thought most updates of this nature work fine. Those that don't: ones performed behind the UI's back (e.g. with MsiSetProperty), and ones that change properties associated with Edit controls whose text has already been changed by the user. Ones that do: enable/disable (such as in response to a radio button on a license dialog). Isn't hide/show in response to a checkbox like the latter? – Michael Urman Apr 01 '11 at 14:25
-
6Actually, they will hide dynamically, I've already tested it. – Bogdan Verbenets Apr 01 '11 at 14:54
2
This is a very old question, and the answer is: Yes it is possible.
I finally get how this works based on this blog post and Bogdan Verbenets's answer. To elaborate already chosen answer, this snippet based on his answer might help you understand more:
<Control Id="AnyCheckBox" Type="CheckBox" Height="17" Width="10" X="150" Y="180" Property="CreateDBUsers" CheckBoxValue="1" />
<Control Id="LoginTextBox" Type="Edit" Text="CM2" Height="17" Width="200" X="150" Y="198" Property="Login">
<Condition Action="hide"><![CDATA[CreateDBUsers<>"1"]]></Condition>
<Condition Action="show">CreateDBUsers="1"</Condition>
</Control>
Which the above code work the same as below:
<Control Id="AnyCheckBox" Type="CheckBox" Height="17" Width="10" X="150" Y="180" Property="CreateDBUsers" CheckBoxValue="0" />
<Control Id="LoginTextBox" Type="Edit" Text="CM2" Height="17" Width="200" X="150" Y="198" Property="Login">
<Condition Action="hide"><![CDATA[CreateDBUsers<>"0"]]></Condition>
<Condition Action="show">CreateDBUsers="0"</Condition>
</Control>
Please pay attention to CheckBoxValue
which its value determine what you going to write in the condition text.
Note:
- It better to use
<![CDATA[ write_something_here ]]>
when you need to write conditional involving<
(less than equal) or>
(greater than equal). - It might more proper to use string (
"1"
,"0"
) in condition text sinceCheckBoxValue
actually use string data type, you can check at official documentation. Although this is not mandatory.
Check box is definitely quite a something different in WiX.

ichan-akira
- 443
- 5
- 15