{"id":193,"date":"2010-04-28T18:32:51","date_gmt":"2010-04-28T18:32:51","guid":{"rendered":"https:\/\/ibex.tech\/visualcpp\/?p=193"},"modified":"2022-02-17T06:24:05","modified_gmt":"2022-02-17T06:24:05","slug":"using-checked-list-box","status":"publish","type":"post","link":"https:\/\/ibex.tech\/visualcpp\/checked-list-box\/using-checked-list-box","title":{"rendered":"Using Checked List Box"},"content":{"rendered":"<h4>General Setup<\/h4>\n<p>To cause the items in the CheckedListBox to be checked when you click them the first time, set the control&#8217;s CheckOnClick property to True.<\/p>\n<h4>Clear All Items<\/h4>\n<pre><code>\r\n\tclbMyCheckedList-&gt;Items-&gt;Clear();\r\n<\/code><\/pre>\n<h4>Clear Individual Items<\/h4>\n<pre><code>\r\n\tclbMyCheckedList-&gt;Items-&gt;RemoveAt(0);\t\t\/\/Specify index position\r\n<\/code><\/pre>\n<h4>Add New Items<\/h4>\n<pre><code>\r\n\tclbMyCheckedList-&gt;BeginUpdate();\t\t\/\/Stop painting of the ListBox as items are added\r\n\tclbMyCheckedList-&gt;Items-&gt;Add(\"Entry 1\", true);\r\n\tclbMyCheckedList-&gt;EndUpdate();\r\n<\/code><\/pre>\n<h4>How Many Items Are Checked?<\/h4>\n<pre><code>\r\n\tcount = clbMyCheckedList-&gt;CheckedItems-&gt;Count\r\n<\/code><\/pre>\n<h4>Is Item Checked?<\/h4>\n<pre><code>\r\n\tfor (Count = 0; Count &lt; clbMyCheckedList-&gt;Items-&gt;Count; Count ++)\r\n\t{\r\n\t\tif (clbMyCheckedList-&gt;GetItemChecked(Count))\r\n<\/code><\/pre>\n<h4>Getting Item String<\/h4>\n<pre><code>\r\nchkTagsList-&gt;GetItemText(chkTagsList-&gt;Items[Count]);\r\n<\/code><\/pre>\n<h4>Setting Checked State<\/h4>\n<pre><code>\r\n\tclbMyCheckedList-&gt;SetItemChecked(Count, true);\r\n\tclbMyCheckedList-&gt;SetItemCheckState(Count, CheckState::Indeterminate);\r\n<\/code><\/pre>\n<h4>Select An Item<\/h4>\n<pre><code>\r\n\tclbMyCheckedList-&gt;SetSelected(index, true);\r\n<\/code><\/pre>\n<h4>Causing value change on first click in a row<\/h4>\n<p>Set &#8220;Check on click&#8221; on<\/p>\n<h4>Item Value Changed<\/h4>\n<pre><code>\r\n\tprivate: System::Void clbIncludedGroups_ItemCheck(System::Object^  sender, System::Windows::Forms::ItemCheckEventArgs^  e)\r\n\t{\r\n\t\tif (e-&gt;NewValue == System::Windows::Forms::CheckState::Checked)\r\n\t\t{\r\n\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\r\n\t\t}\r\n\t}\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>General Setup To cause the items in the CheckedListBox to be checked when you click them the first time, set the control&#8217;s CheckOnClick property to True. Clear All Items clbMyCheckedList-&gt;Items-&gt;Clear(); Clear Individual Items clbMyCheckedList-&gt;Items-&gt;RemoveAt(0); \/\/Specify index position Add New Items clbMyCheckedList-&gt;BeginUpdate(); \/\/Stop painting of the ListBox as items are added clbMyCheckedList-&gt;Items-&gt;Add(&#8220;Entry 1&#8221;, true); clbMyCheckedList-&gt;EndUpdate(); How [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[],"class_list":["post-193","post","type-post","status-publish","format-standard","hentry","category-checked-list-box"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/193","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/comments?post=193"}],"version-history":[{"count":4,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/193\/revisions"}],"predecessor-version":[{"id":1129,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/193\/revisions\/1129"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/media?parent=193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/categories?post=193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/tags?post=193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}