C# 单击文本或复选框后显示矩形

C# 单击文本或复选框后显示矩形,c#,winforms,checkbox,C#,Winforms,Checkbox,我有一个窗口应用程序,它有一些复选框。这些复选框具有图像,并且外观设置为“按钮” 我的问题是,当我单击复选框时,复选框周围会出现一个矩形,如下所示。我没有得到我应该设置什么属性来避免这个矩形 this.chkboxReportSelect.Appearance = System.Windows.Forms.Appearance.Button; this.chkboxReportSelect.BackColor = System.Drawing.Color.FromArgb(((int)(((by

我有一个窗口应用程序,它有一些复选框。这些复选框具有图像,并且外观设置为“按钮”

我的问题是,当我单击复选框时,复选框周围会出现一个矩形,如下所示。我没有得到我应该设置什么属性来避免这个矩形

this.chkboxReportSelect.Appearance = System.Windows.Forms.Appearance.Button;
this.chkboxReportSelect.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(215)))), ((int)(((byte)(221)))), ((int)(((byte)(228)))));
this.chkboxReportSelect.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(215)))), ((int)(((byte)(221)))), ((int)(((byte)(228)))));
this.chkboxReportSelect.FlatAppearance.BorderSize = 0;
this.chkboxReportSelect.FlatAppearance.CheckedBackColor = System.Drawing.Color.Transparent;
this.chkboxReportSelect.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent;
this.chkboxReportSelect.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent;
this.chkboxReportSelect.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.chkboxReportSelect.Image = global::M3.AKFRW.UI.Properties.Resources.checkmark;
this.chkboxReportSelect.Location = new System.Drawing.Point(3, 3);
this.chkboxReportSelect.Name = "chkboxReportSelect";
this.chkboxReportSelect.Size = new System.Drawing.Size(124, 24);
this.chkboxReportSelect.TabIndex = 27;
this.chkboxReportSelect.Text = "Select Report ";
this.chkboxReportSelect.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
this.chkboxReportSelect.UseCompatibleTextRendering = true;
this.chkboxReportSelect.UseVisualStyleBackColor = false;


我假设您正在使用
平面样式
。您看到的矩形是FlatStyle的边框,您可以通过将
FlatAppearance
BorderSize
设置为
0

checkbox.FlatAppearance.BorderSize = 0;

控件是什么?它实际上是一个
按钮
?它是一个复选框,但它的外观设置为Button..我在没有图像的情况下选中了此代码,它工作正常。我怀疑图像中可能有什么东西;或者选中事件中的复选框。可能是某个事件改变了Runtime中的属性。我已将此属性设置为0,但它仍显示边框。然后请发布代码以重现此问题,否则我们将不得不猜测我已找到此矩形出现的原因。在操作系统控制面板中,我们有一个名为的属性“轻松访问中心>>使键盘更易于使用>>为键盘快捷键和访问键加下划线”。请检查此属性是否为true以及出现的此问题。