title: Panel scrolling automatically
body: <p>I have an <code>UserControl</code> and inside it I have some controls and one of these controls is a <code>CheckBox</code>. This <code>CheckBox</code> performs a <code>CheckedChanged</code> action that calls a method and this method sets some of the controls of the <code>Panel</code> to <code>Enabled</code> or <code>Visible</code>.</p>
  
  <p>When I click to check the <code>CheckBox</code> the <code>Panel</code> where all these controls are inserted scrolls down automatically like the images below.</p>
  
  <p>How could I stop the <code>Panel</code> scrolling down after checking the <code>CheckBox</code>?</p>
  
  <p><a href="https://i.stack.imgur.com/qCVhe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qCVhe.png" alt="enter image description here"></a>
  Inicial position</p>
  
  <p><a href="https://i.stack.imgur.com/7SJ4m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7SJ4m.png" alt="enter image description here"></a>
  Position after checking the CheckBox</p>
  
  <p>The code is below</p>
  
  <p>The CheckBox Action</p>
  
  <pre><code>private void usuarioMedicoCheckBox_CheckedChanged(object sender, EventArgs e)
          {
              if(usuarioMedicoCheckBox.Checked)
              {
                  carregarMedicos();
              } else
              {
                  medicos = null;
              }
  
              usuarioMedicoComboBox.Enabled = usuarioMedicoCheckBox.Checked;
              cadastrarMedicoButton.Enabled = usuarioMedicoCheckBox.Checked;
          }
  </code></pre>
  
  <p>Method carregarMedico</p>
  
  <pre><code>private void carregarMedicos()
          {
              processandoDados(true);
  
              ParseQuery&lt;Classes.Medico&gt; query = new ParseQuery&lt;Classes.Medico&gt;();
  
              query.OrderBy("nomeCompleto").FindAsync().ContinueWith(resultado =&gt; {
                  if (resultado.IsCompleted &amp;&amp; !resultado.IsFaulted)
                  {
                      medicos = resultado.Result.ToList();
  
                      atualizarMedicosComboBoxDelegate atualizarMedicosComboBoxD = new atualizarMedicosComboBoxDelegate(atualizarMedicosComboBox);
                      this.Invoke(atualizarMedicosComboBoxD, new object[] { });
                  } else
                  {
                      MessageBox.Show("Houve um erro ao buscar os médicos", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                  }
  
                  processandoDadosDelegate processandoDadosD = new processandoDadosDelegate(processandoDados);
                  this.Invoke(processandoDadosD, new object[] { false });
              });
          }
  </code></pre>
  
  <p>Method atualizarMedicosComboBox</p>
  
  <pre><code>private void atualizarMedicosComboBox()
          {
              usuarioMedicoComboBox.Items.Clear();
  
              if (medicos != null &amp;&amp; medicos.Count() &gt; 0)
              {
                  foreach(Classes.Medico medico in medicos)
                  {
                      usuarioMedicoComboBox.Items.Add(medico.nomeCompleto);
                  }
              } else
              {
                  usuarioMedicoComboBox.Items.Add("Não há médicos cadastrados");
              }
          }
  </code></pre>
  
  <p>Method processandoDados</p>
  
  <pre><code>private void processandoDados(bool acao)
          {
              if (acao)
              {
                  nomeCompletoTextBox.Enabled = false;
                  emailTextBox.Enabled = false;
                  cpfMaskedTextBox.Enabled = false;
                  selecionarFotoButton.Enabled = false;
                  usuarioMedicoCheckBox.Enabled = false;
                  usuarioMedicoComboBox.Enabled = false;
                  cadastrarMedicoButton.Enabled = false;
                  usuarioAdmCheckBox.Enabled = false;
                  permissoesPacientesGroupBox.Enabled = false;
                  permissoesMedicosGroupBox.Enabled = false;
                  permissoesUsuariosGroupBox.Enabled = false;
                  salvarUsuarioButton.Visible = false;
                  salvarUsuarioProgressBar.Visible = true;
              } else
              {
                  nomeCompletoTextBox.Enabled = true;
                  emailTextBox.Enabled = true;
                  cpfMaskedTextBox.Enabled = true;
                  selecionarFotoButton.Enabled = true;
                  usuarioMedicoCheckBox.Enabled = true;
  
                  if (usuarioMedicoCheckBox.Checked)
                  {
                      usuarioMedicoComboBox.Enabled = true;
                      cadastrarMedicoButton.Enabled = true;
                  }
                  else
                  {
                      usuarioMedicoComboBox.Enabled = false;
                      cadastrarMedicoButton.Enabled = false;
                  }
  
                  usuarioAdmCheckBox.Enabled = true;
                  salvarUsuarioButton.Visible = true;
                  salvarUsuarioProgressBar.Visible = false;
  
                  if(!usuarioAdmCheckBox.Checked)
                  {
                      permissoesPacientesGroupBox.Enabled = true;
                      permissoesMedicosGroupBox.Enabled = true;
                      permissoesUsuariosGroupBox.Enabled = true;
                  }
              }
          }
  </code></pre>