Image Settings in WinForms CheckBox
18 Nov 20183 minutes to read
You can set the images to the WinForms CheckBox when it is in the Checked, Unchecked or Indeterminate state using ImageCheckBox,ImageCheckBoxSize,CheckedImage,UncheckedImage,IndeterminateImage,DisabledImage and StretchImage properties.
| WinForms CheckBox Properties | Description |
|---|---|
| ImageCheckBox | Indicates whether the WinForms CheckBox will be drawn using the images provided. |
| ImageCheckBoxSize | Gets or sets the size of the ImageCheckBox.ImageCheckbox property must be set to 'True'. |
| CheckedImage | Gets or sets the image used to draw the WinForms CheckBox when checked and mouse not over. |
| UncheckedImage | Gets or sets the image used to draw the WinForms CheckBox when unchecked and mouse not over. |
| IndeterminateImage | The image used to draw the WinForms CheckBox when indeterminate and mouse not over. |
| DisabledImage | Gets or sets the image used to draw the WinForms CheckBox when disabled. |
| StretchImage | Indicates whether the state images of the WinForms CheckBox are stretched. |
Before setting the images, make sure the ImageCheckBox property is set to ‘True’.
this.checkBoxAdv1.ImageCheckBox = true;
this.checkBoxAdv1.ImageCheckBoxSize = new System.Drawing.Size(15, 15);
this.checkBoxAdv1.CheckedImage = ((System.Drawing.Image)(resources.GetObject("checkBoxAdv1.CheckedImage")));
this.checkBoxAdv1.UncheckedImage = ((System.Drawing.Image)(resources.GetObject("checkBoxAdv1.UncheckedImage")));
this.checkBoxAdv1.IndeterminateImage = ((System.Drawing.Image)(resources.GetObject("checkBoxAdv1.IndeterminateImage")));
this.checkBoxAdv1.DisabledImage = ((System.Drawing.Image)(resources.GetObject("checkBoxAdv1.DisabledImage")));
this.checkBoxAdv1.StretchImage = false;Me.checkBoxAdv1.ImageCheckBox = True
Me.checkBoxAdv1.ImageCheckBoxSize = New System.Drawing.Size(15, 15)
Me.checkBoxAdv1.CheckedImage = (CType(Resources.GetObject("checkBoxAdv1.CheckedImage"), System.Drawing.Image))
Me.checkBoxAdv1.UncheckedImage = (CType(Resources.GetObject("checkBoxAdv1.UncheckedImage"), System.Drawing.Image))
Me.checkBoxAdv1.IndeterminateImage = (CType(Resources.GetObject("checkBoxAdv1.IndeterminateImage"), System.Drawing.Image))
Me.checkBoxAdv1.DisabledImage = (CType(Resources.GetObject("checkBoxAdv1.DisabledImage"), System.Drawing.Image))
Me.checkBoxAdv1.StretchImage = False
Images displayed during Mouse Hover
You can set the image in WinForms CheckBox control when the mouse is hovered over it using MouseOverCheckedImage,MouseOverIndetermImage and MouseOverUncheckedImage properties.
| WinForms CheckBox Properties | Description |
|---|---|
| MouseOverCheckedImage | Gets or sets the image used to draw the WinForms CheckBox when checked and mouse over. |
| MouseOverIndetermImage | Gets or sets the image used to draw the WinForms CheckBox when indeterminate and mouse over. |
| MouseOverUncheckedImage | Gets or sets the image used to draw the WinForms CheckBox when unchecked and mouse over. |
this.checkBoxAdv1.MouseOverCheckedImage = ((System.Drawing.Image)(resources.GetObject("checkBoxAdv1.MouseOverCheckedImage")));
this.checkBoxAdv1.MouseOverIndetermImage = ((System.Drawing.Image)(resources.GetObject("checkBoxAdv1.MouseOverIndetermImage")));
this.checkBoxAdv1.MouseOverUncheckedImage = ((System.Drawing.Image)(resources.GetObject("checkBoxAdv1.MouseOverUncheckedImage")));Me.checkBoxAdv1.MouseOverCheckedImage = (CType(Resources.GetObject("checkBoxAdv1.MouseOverCheckedImage"), System.Drawing.Image))
Me.checkBoxAdv1.MouseOverIndetermImage = (CType(Resources.GetObject("checkBoxAdv1.MouseOverIndetermImage"), System.Drawing.Image))
Me.checkBoxAdv1.MouseOverUncheckedImage = (CType(Resources.GetObject("checkBoxAdv1.MouseOverUncheckedImage"), System.Drawing.Image))