{"id":3148,"date":"2011-06-29T07:15:00","date_gmt":"2011-06-29T15:15:00","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/?p=3148"},"modified":"2011-06-29T07:15:22","modified_gmt":"2011-06-29T15:15:22","slug":"primalforms-2011-spotlight-on-the-checkbox-control","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2011\/06\/29\/primalforms-2011-spotlight-on-the-checkbox-control\/","title":{"rendered":"PrimalForms 2011: Spotlight on the CheckBox control"},"content":{"rendered":"<p>The \u201cSpotlight on Controls\u201d series focuses on a single WinForms control in PrimalForms 2011 , details the important Properties, Methods, and Events of the control and demonstrates how to utilize the control. Most of the information about the controls is still applicable to previous versions of PrimalForms.<\/p>\n<p>Last time we took a look at the <a href=\"http:\/\/www.sapien.com\/blog\/2011\/06\/21\/primalforms-2011-spotlight-on-the-combobox-control\/\">ComboBox<\/a> control. This time we will look at the CheckBox control:<\/p>\n<p><font size=\"4\"><strong>CheckBox Control <\/strong>[System.Windows.Forms.CheckBox]<\/font><\/p>\n<p>Represents a Windows check box control.  <\/p>\n<p>Default Event: CheckedChanged<\/td>\n<\/p>\n<p><em>Why use the CheckBox control?<\/em>  <\/p>\n<p>Use the CheckBox control to retrieve or display True \/ False values .<\/p>\n<p><strong><font size=\"3\">Important Properties:<\/font><\/strong><\/p>\n<p><strong>Checked<\/strong>  <\/p>\n<p>Indicates whether the checkbox is in the checked state.  <\/p>\n<p>Values (Default: <em>False<\/em>):  <\/p>\n<blockquote>\n<p><em>True<\/em><\/p>\n<p>&nbsp;<img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Checked\" border=\"0\" alt=\"Checked\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2011\/06\/Checked.png\" width=\"86\" height=\"26\"><\/p>\n<p><em>False<\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Unchecked\" border=\"0\" alt=\"Unchecked\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2011\/06\/Unchecked.png\" width=\"100\" height=\"31\"><\/p>\n<\/blockquote>\n<p>Set the Checked property in the editor: <\/p>\n<pre><span style=\"color: #8b0000\">$checkbox1<\/span><span style=\"color: #000000\">.Checked <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$true<\/span><\/pre>\n<p>&nbsp; <\/p>\n<p><strong>CheckAlign<\/strong><\/p>\n<p>Determines the location of the checkbox inside the control. <\/p>\n<p><em>Why use the CheckAlign property?<\/em>&nbsp; <\/p>\n<p>Use the CheckAlign property when you want to change the location of the check box in respect to the control\u2019s space. <\/p>\n<p>Values (Default: <em>MiddleLeft<\/em>): <\/p>\n<blockquote>\n<p><em>TopLeft<\/em><br \/>Content is vertically aligned at the top and horizontally aligned on the left. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"TopLeft\" border=\"0\" alt=\"TopLeft\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2011\/06\/TopLeft.png\" width=\"128\" height=\"63\"> <\/p>\n<p><em>TopCenter<\/em><br \/>Content is vertically aligned at the top and horizontally aligned at the center. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"TopCenter\" border=\"0\" alt=\"TopCenter\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2011\/06\/TopCenter.png\" width=\"131\" height=\"57\"> <\/p>\n<p><em>TopRight<\/em><br \/>Content is vertically aligned at the top and horizontally aligned on the right. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"TopRight\" border=\"0\" alt=\"TopRight\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2011\/06\/TopRight.png\" width=\"122\" height=\"59\"> <\/p>\n<p><em>MiddleLeft<\/em><br \/>Content is vertically aligned in the middle and horizontally aligned on the left. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"MiddleLeft\" border=\"0\" alt=\"MiddleLeft\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2011\/06\/MiddleLeft.png\" width=\"124\" height=\"56\"> <\/p>\n<p><em>MiddleCenter<\/em><br \/>Content is vertically aligned in the middle and horizontally aligned at the center. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"MiddleCenter\" border=\"0\" alt=\"MiddleCenter\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2011\/06\/MiddleCenter.png\" width=\"126\" height=\"58\"> <\/p>\n<p><em>MiddleRight<\/em><br \/>Content is vertically aligned in the middle and horizontally aligned on the right. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"MiddleRight\" border=\"0\" alt=\"MiddleRight\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2011\/06\/MiddleRight.png\" width=\"122\" height=\"60\"> <\/p>\n<p><em>BottomLeft<\/em><br \/>Content is vertically aligned at the bottom and horizontally aligned on the left. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"BottomLeft\" border=\"0\" alt=\"BottomLeft\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2011\/06\/BottomLeft.png\" width=\"126\" height=\"57\"> <\/p>\n<p><em>BottomCenter<\/em><br \/>Content is vertically aligned at the bottom and horizontally aligned at the center. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"BottomCenter\" border=\"0\" alt=\"BottomCenter\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2011\/06\/BottomCenter.png\" width=\"123\" height=\"60\"> <\/p>\n<p><em>BottomRight<\/em><br \/>Content is vertically aligned at the bottom and horizontally aligned on the right. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"BottomRight\" border=\"0\" alt=\"BottomRight\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2011\/06\/BottomRight.png\" width=\"124\" height=\"58\"><\/p>\n<\/blockquote>\n<p><strong>TextAlign<\/strong><\/p>\n<p>The alignment of the text that will be displayed on the control.<\/p>\n<p>Values (Default: <em>MiddleLeft<\/em>): <\/p>\n<blockquote>\n<p>Shares the same values as CheckAlign property.<\/p>\n<\/blockquote>\n<p>&nbsp;<\/p>\n<p><strong><font size=\"3\">Important Events:<\/font><\/strong><\/p>\n<p><strong>CheckedChanged<\/strong> <\/p>\n<p>Occurs whenever the Check property is changed. <\/p>\n<p><strong><\/strong><em>Why use the CheckedChanged event?<\/em><\/p>\n<p>Use the CheckedChanged event when you wish to respond to when a user changes the check box state by modifying the form controls or running a script . For example, you may wish to disable certain controls depending on the checkbox\u2019s current value. <\/p>\n<p>In this example,&nbsp; the event script disables the input textboxes for UserName and Password when the \u201cUse Alternate Credentials\u201d checkbox is unchecked.<\/p>\n<pre><span style=\"color: #8b0000\">$checkboxUseAltCred_CheckedChanged<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\">{\n    <\/span><span style=\"color: #008000\">#Enable or Disable the TextBox controls<\/span><span style=\"color: #000000\">\n    <\/span><span style=\"color: #8b0000\">$textboxUserName<\/span><span style=\"color: #000000\">.Enabled <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$checkboxUseAltCred<\/span><span style=\"color: #000000\">.Checked\n    <\/span><span style=\"color: #8b0000\">$textboxPassword<\/span><span style=\"color: #000000\">.Enabled <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$checkboxUseAltCred<\/span><span style=\"color: #000000\">.Checked\n}<\/span><\/pre>\n<p>When the checkbox is unchecked, the textboxes are disabled:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"OnCheckedChanged Unchecked\" border=\"0\" alt=\"OnCheckedChanged Unchecked\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2011\/06\/OnCheckedChanged-Unchecked.png\" width=\"304\" height=\"213\"><\/p>\n<p>When the checkbox is checked, the textboxes are enabled:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"OnCheckedChanged Checked\" border=\"0\" alt=\"OnCheckedChanged Checked\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2011\/06\/OnCheckedChanged-Checked.png\" width=\"304\" height=\"213\"><\/p>\n<p><strong><\/strong>&nbsp;<\/p>\n<p><strong>Next on Spotlight on Controls:<\/strong><\/p>\n<p>The RadioButton control.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The \u201cSpotlight on Controls\u201d series focuses on a single WinForms control in PrimalForms 2011 , details the important Properties, Methods, and Events of the control and demonstrates how to utilize the control. Most of the information about the controls is still applicable to previous versions of PrimalForms. Last time we took a look at the [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[575,644,25],"tags":[661,641,28,633,327],"class_list":["post-3148","post","type-post","status-publish","format-standard","hentry","category-primalforms-2011-software-news","category-spotlight-on-controls","category-windows-powershell","tag-checkbox","tag-controls","tag-powershell","tag-primalforms-2011","tag-winform"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/3148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=3148"}],"version-history":[{"count":2,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/3148\/revisions"}],"predecessor-version":[{"id":3153,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/3148\/revisions\/3153"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=3148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=3148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=3148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}