我有一个TabControl控件!里面分别有两个TabPage!每一个TabPage我都会设置一个BackgroundImage.但是设置完以后总会发现这个TabPage外面会有一个边框!我仔细查看了是这个TabControl控件的边框!小妹求救了!如何去掉这个边框或者让它成为透明色!谢谢各位师哥了!

解决方案 »

  1.   

    this.tabPage1.BorderStyle = BorderStyle.None;
      

  2.   

    这是我窗体设计代码!#region Windows 窗体设计器生成的代码        /// <summary>
            /// 设计器支持所需的方法 - 不要
            /// 使用代码编辑器修改此方法的内容。
            /// </summary>
            private void InitializeComponent()
            {
                System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
                this.tabControl1 = new System.Windows.Forms.TabControl();
                this.tabPage1 = new System.Windows.Forms.TabPage();
                this.tabPage2 = new System.Windows.Forms.TabPage();
                this.button1 = new System.Windows.Forms.Button();
                this.checkBox1 = new System.Windows.Forms.CheckBox();
                this.tabControl1.SuspendLayout();
                this.tabPage1.SuspendLayout();
                this.tabPage2.SuspendLayout();
                this.SuspendLayout();
                // 
                // tabControl1
                // 
                this.tabControl1.Controls.Add(this.tabPage1);
                this.tabControl1.Controls.Add(this.tabPage2);
                this.tabControl1.Location = new System.Drawing.Point(36, 71);
                this.tabControl1.Name = "tabControl1";
                this.tabControl1.SelectedIndex = 0;
                this.tabControl1.Size = new System.Drawing.Size(223, 143);
                this.tabControl1.TabIndex = 0;
                // 
                // tabPage1
                // 
                this.tabPage1.BackColor = System.Drawing.Color.Black;
                this.tabPage1.Controls.Add(this.button1);
                this.tabPage1.Location = new System.Drawing.Point(4, 21);
                this.tabPage1.Name = "tabPage1";
                this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
                this.tabPage1.Size = new System.Drawing.Size(215, 118);
                this.tabPage1.TabIndex = 0;
                this.tabPage1.Text = "tabPage1";
                this.tabPage1.UseVisualStyleBackColor = true;
                // 
                // tabPage2
                // 
                this.tabPage2.BackColor = System.Drawing.Color.Silver;
                this.tabPage2.BorderStyle = BorderStyle.None;
                this.tabPage2.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("tabPage2.BackgroundImage")));
                this.tabPage2.Controls.Add(this.checkBox1);
                this.tabPage2.Location = new System.Drawing.Point(4, 21);
                this.tabPage2.Name = "tabPage2";
                this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
                this.tabPage2.Size = new System.Drawing.Size(215, 118);
                this.tabPage2.TabIndex = 1;
                this.tabPage2.Text = "tabPage2";
                this.tabPage2.UseVisualStyleBackColor = true;
                // 
                // button1
                // 
                this.button1.Location = new System.Drawing.Point(27, 40);
                this.button1.Name = "button1";
                this.button1.Size = new System.Drawing.Size(75, 23);
                this.button1.TabIndex = 0;
                this.button1.Text = "button1";
                this.button1.UseVisualStyleBackColor = true;
                // 
                // checkBox1
                // 
                this.checkBox1.AutoSize = true;
                this.checkBox1.Location = new System.Drawing.Point(73, 52);
                this.checkBox1.Name = "checkBox1";
                this.checkBox1.Size = new System.Drawing.Size(78, 16);
                this.checkBox1.TabIndex = 0;
                this.checkBox1.Text = "checkBox1";
                this.checkBox1.UseVisualStyleBackColor = true;
                // 
                // Form1
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
                this.ClientSize = new System.Drawing.Size(292, 266);
                this.Controls.Add(this.tabControl1);
                this.Name = "Form1";
                this.Text = "Form1";
                this.tabControl1.ResumeLayout(false);
                this.tabPage1.ResumeLayout(false);
                this.tabPage2.ResumeLayout(false);
                this.tabPage2.PerformLayout();
                this.ResumeLayout(false);        }        #endregion
      

  3.   

    TabControl控件里设置border="0"可以么?
      

  4.   

    我是WinFrom程序没有border属性!
      

  5.   

    有个 Padding 的属性默认是3,3,3,3  你改成 0,0,0,0
    还有个 Margin 默认的也是 3,3,3,3  你也改成 0,0,0,0
    试下
      

  6.   


    TabPage.borderstyle=BorderStyle.None;
    试下。
      

  7.   

    图片没问题!是充满整个窗体的图片!
    TabPage.borderstyle=BorderStyle.None;
    也没有用
      

  8.   

    用下面这个:tabContain.Appearance = TabAppearance.FlatButtons;
      

  9.   

    这个是Windows主题的问题~ 今天我也出现了这个问题~ 改了好几次主题~ 最后边框就没了~ 
    以前我做WPF 程序时也出现过按钮变丑了的问题~ 发现也是主题的原因~ 呵呵~ 因为有些主题跟微软的软件不是完全兼容~