title: Determination of the number of checked items of the CheckedListBox, WinForms
body: <p>In my program for WinForms I have element <strong>CheckedListBox</strong>.</p>
  
  <p>I have two problems with it:</p>
  
  <ol>
  <li>It is necessary to disable the ability to mark the new fields if already was marked 3;</li>
  <li>It should not completely disable an element, like I do. If you check 3 items and then uncheck one of them, then again, it should be possible to makr one more. And I completely disable CheckedListBox. I do not know how to do it right.</li>
  </ol>
  
  <p><img src="https://i.stack.imgur.com/hZFiX.jpg" alt="enter image description here"></p>
  
  <pre><code>private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
  {
      // Always print '1':
      MessageBox.Show(checkedListBox1.SelectedItems.Count.ToString());
      if (checkedListBox1.SelectedItems.Count == 3)
          checkedListBox1.Enabled = false;
  }
  </code></pre>