Select to view content in your preferred language

how to default select checkbox

663
5
Jump to solution
05-30-2023 11:57 PM
LSCGIS
by
New Contributor

I Add a ChekBox using ArcGIS Pro SDK For .NET,how to make it default select。The code below dosn't work. Thanks!

internal class CheckBoxSimplify : ArcGIS.Desktop.Framework.Contracts.CheckBox
{
public CheckBoxSimplify()
{
IsChecked = true;//do not work
}

protected override void OnClick()
{
ModuleSAM.Current.IsSimplify = IsChecked.Value;
base.OnClick();
}
}

0 Kudos
1 Solution

Accepted Solutions
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Understood, in my example i set the attribute

isChecked="true"

in my config.daml definition of the checkBox to true.   That initializes my checkBox on the screen to 'Checked' when i start Pro.   But you are correct the code-behind doesn't get called until JIT (Just In Time) triggers loading and the execution of the code.   So @LSCGIS  would have to set isChecked to true in the DAML and also initialize  ModuleSAM.Current.IsSimplify  to 'true' to keep the checkbox and the property in sync.  If this the case then the loadOnClick  value is irrelevant.

View solution in original post

0 Kudos
5 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

Try to check add-in daml file. Your checkbox loadOnClick value must be set to false:

<checkBox id="RibbonControls_CheckBox1" keytip="XC" caption="CheckBox 1" className="CheckBox1" loadOnClick="false">
 <tooltip heading="CheckBox1 Tooltip Heading">
  CheckBox1 Tooltip Heading. 
  <disabledText /> 
  </tooltip>
  </checkBox>

And rebuild solution after changes

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

This worked for me:  At startup I see this:

Wolf_0-1685553224115.png

Using this DAML syntax:

<checkBox id="TestTool_Checkbox" caption="Check Here!" 
          isChecked="true" className="CheckBoxSimplify" 
          keytip="C1" >
  <tooltip heading="Check Here!">
    Test for default being checked<disabledText />
  </tooltip>
</checkBox>

 

0 Kudos
GKmieliauskas
Esri Regular Contributor

I have tried with ArcGIS Pro sdk community sample RibbonControls

In sample original loadOnClick value is false. If I change it to true it works as @LSCGIS wrote, because object constructor is not activated until first checkbox click

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Understood, in my example i set the attribute

isChecked="true"

in my config.daml definition of the checkBox to true.   That initializes my checkBox on the screen to 'Checked' when i start Pro.   But you are correct the code-behind doesn't get called until JIT (Just In Time) triggers loading and the execution of the code.   So @LSCGIS  would have to set isChecked to true in the DAML and also initialize  ModuleSAM.Current.IsSimplify  to 'true' to keep the checkbox and the property in sync.  If this the case then the loadOnClick  value is irrelevant.

0 Kudos
LSCGIS
by
New Contributor

Thanks to both of you!

Set isChecked="true" in config.daml works for me.

Set loadOnClick="false" and Set IsChecked = true in ModuleSAM.Current.IsSimplify works same.

0 Kudos