{"id":170,"date":"2016-03-01T11:09:55","date_gmt":"2016-03-01T11:09:55","guid":{"rendered":"https:\/\/ibex.tech\/csharp\/?p=170"},"modified":"2022-02-17T06:24:14","modified_gmt":"2022-02-17T06:24:14","slug":"using-checked-list-box","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/c-sharp\/checked-list-box\/using-checked-list-box","title":{"rendered":"Using Checked List Box"},"content":{"rendered":"<h4>\n\tGeneral Setup<br \/>\n<\/h4>\n<p>\n\tTo cause the items in the CheckedListBox to be checked when you click them the first time, set the control&#39;s CheckOnClick property to True.\n<\/p>\n<h4>\n\tClear All Items<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n\tclbMyCheckedList.Items.Clear();\r\n<\/code><\/pre>\n<h4>\n\tClear Individual Items<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n\tclbMyCheckedList.Items.RemoveAt(0);\t\t\/\/Specify index position\r\n<\/code><\/pre>\n<h4>\n\tAdd New Items<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n\tclbMyCheckedList.BeginUpdate();\t\t\/\/Stop painting of the ListBox as items are added\r\n\tclbMyCheckedList.Items.Add(&quot;Entry 1&quot;, true);\r\n\tclbMyCheckedList.EndUpdate();\r\n<\/code><\/pre>\n<h4>\n\tHow Many Items Are Checked?<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n\tcount = clbMyCheckedList.CheckedItems.Count\r\n<\/code><\/pre>\n<h4>\n\tIs Item Checked?<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n\tfor (Count = 0; Count &lt; clbMyCheckedList.Items.Count; Count++)\r\n\t{\r\n\t\tif (clbMyCheckedList.GetItemChecked(Count))\r\n<\/code><\/pre>\n<h4>\n\tGetting Item String<br \/>\n<\/h4>\n<pre>\r\n<code>\r\nchkTagsList.&gt;GetItemText(chkTagsList.Items[Count]);\r\n<\/code><\/pre>\n<h4>\n\tSetting Checked State<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n\tclbMyCheckedList.SetItemChecked(Count, true);\r\n\tclbMyCheckedList.SetItemCheckState(Count, CheckState.Indeterminate);\r\n<\/code><\/pre>\n<h4>\n\tSelect An Item<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n\tclbMyCheckedList.SetSelected(index, true);\r\n<\/code><\/pre>\n<h4>\n\tCausing value change on first click in a row<br \/>\n<\/h4>\n<p>\n\tSet &quot;Check on click&quot; on\n<\/p>\n<h4>\n\tItem Value Changed<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n\tprivate void clbIncludedGroups_ItemCheck(object sender, ItemCheckEventArgs e)\r\n\t{\r\n\t\tif (e.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<p>\n\t&nbsp;\n<\/p>\n<p>\n\t&nbsp;<\/p>\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&#39;s CheckOnClick property to True. Clear All Items clbMyCheckedList.Items.Clear(); Clear Individual Items clbMyCheckedList.Items.RemoveAt(0); \/\/Specify index position Add New Items clbMyCheckedList.BeginUpdate(); \/\/Stop painting of the ListBox as items are added clbMyCheckedList.Items.Add(&quot;Entry 1&quot;, true); clbMyCheckedList.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":[33],"tags":[],"class_list":["post-170","post","type-post","status-publish","format-standard","hentry","category-checked-list-box"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/170","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=170"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/170\/revisions"}],"predecessor-version":[{"id":172,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/170\/revisions\/172"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}