title: How can the visibility of a button in a form be changed dynamically using x++ code?
body: <p>How can I change the visibility of my button control <code>MyButton</code>?</p>
  
  <p>I have a form <code>MyForm</code> where I want to set the visibility property for my <code>MyButton</code> button control.
  I used this code in the form's <code>init</code> method:</p>
  
  <pre><code>public void init()
  {
      MyTable myTable;
      ;
  
      while select myTable where myTable.UserId == curUserId()
      {
          if (myTable.FlagField == NoYes::Yes )
          {
              myButton.visible(true);
          }
          if (!myTable.FlagField == NoYes::No )
          {
              myButton.visible(false);
          }
      }
  
      super();
  }
  </code></pre>
  
  <p>The property <code>AutoDeclaration</code> of <code>MyButton</code> is set to <code>Yes</code>. But when I open the form, I get the following error:</p>
  
  <blockquote>
    <p>"Failure initializing FormButtonControl object." </p>
  </blockquote>
  
  <p>I think I have to use the FormButtonControl class, but I no have idea how to do that.</p>