<bdo id='guFtM'></bdo><ul id='guFtM'></ul>
    1. <legend id='guFtM'><style id='guFtM'><dir id='guFtM'><q id='guFtM'></q></dir></style></legend>

    2. <small id='guFtM'></small><noframes id='guFtM'>

    3. <i id='guFtM'><tr id='guFtM'><dt id='guFtM'><q id='guFtM'><span id='guFtM'><b id='guFtM'><form id='guFtM'><ins id='guFtM'></ins><ul id='guFtM'></ul><sub id='guFtM'></sub></form><legend id='guFtM'></legend><bdo id='guFtM'><pre id='guFtM'><center id='guFtM'></center></pre></bdo></b><th id='guFtM'></th></span></q></dt></tr></i><div id='guFtM'><tfoot id='guFtM'></tfoot><dl id='guFtM'><fieldset id='guFtM'></fieldset></dl></div>
      1. <tfoot id='guFtM'></tfoot>

        如何更改 C# winforms 中未使用空间选项卡的背景颜

        时间:2023-06-04

          • <i id='00Ivi'><tr id='00Ivi'><dt id='00Ivi'><q id='00Ivi'><span id='00Ivi'><b id='00Ivi'><form id='00Ivi'><ins id='00Ivi'></ins><ul id='00Ivi'></ul><sub id='00Ivi'></sub></form><legend id='00Ivi'></legend><bdo id='00Ivi'><pre id='00Ivi'><center id='00Ivi'></center></pre></bdo></b><th id='00Ivi'></th></span></q></dt></tr></i><div id='00Ivi'><tfoot id='00Ivi'></tfoot><dl id='00Ivi'><fieldset id='00Ivi'></fieldset></dl></div>

            <tfoot id='00Ivi'></tfoot>

              <tbody id='00Ivi'></tbody>

              <small id='00Ivi'></small><noframes id='00Ivi'>

              <legend id='00Ivi'><style id='00Ivi'><dir id='00Ivi'><q id='00Ivi'></q></dir></style></legend>
                • <bdo id='00Ivi'></bdo><ul id='00Ivi'></ul>
                  本文介绍了如何更改 C# winforms 中未使用空间选项卡的背景颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                    |Tab1|Tab2|Tab3| {    }
                    |                     |
                    |                     |
                    |                     |
                    |                     |
                    |_____________________|
                  

                  我可以改变 Tabbackcolorforecolor.. 但我想改变那个 { } 的颜色 --> 空白空间可以做到这一点...它显示默认的winforms颜色..帮助我在dis..

                  I am able to change the backcolor and forecolor of Tab.. but I want to change the color of that { } -- > Empty space is this possible to do that. .. It shows default winforms color..help me in dis..

                   private void Form1_Load(object sender, EventArgs e)
                      {
                  
                      }
                  
                  
                      private void tabControl1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
                      {
                          Font fntTab;
                          Brush bshBack;
                          Brush bshFore;
                  
                          if ( e.Index == this.tabControl1.SelectedIndex)
                          {
                              fntTab = new Font(e.Font, FontStyle.Bold);
                              bshBack = new System.Drawing.Drawing2D.LinearGradientBrush(e.Bounds, SystemColors.Control, SystemColors.Control, System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal);
                              bshFore = Brushes.Black;
                              //bshBack = new System.Drawing.Drawing2D.LinearGradientBrush(e.Bounds, Color.LightSkyBlue , Color.LightGreen, System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal);
                              //bshFore = Brushes.Blue;
                          }
                          else
                          {
                              fntTab = e.Font;
                              bshBack = new SolidBrush(Color.Red);
                              bshFore = new SolidBrush(Color.Aqua);
                  
                              //bshBack = new SolidBrush(Color.White);
                              //bshFore = new SolidBrush(Color.Black);
                          }
                  
                          string tabName  = this.tabControl1.TabPages[e.Index].Text;
                          StringFormat sftTab = new StringFormat();
                          e.Graphics.FillRectangle(bshBack, e.Bounds);
                          Rectangle  recTab = e.Bounds;
                          recTab = new Rectangle( recTab.X,  recTab.Y + 4,  recTab.Width,  recTab.Height - 4);
                          e.Graphics.DrawString(tabName, fntTab, bshFore, recTab, sftTab);
                  
                      }
                  

                  推荐答案

                  我认为给那个空间一个颜色的唯一方法是覆盖窗口的 OnPaintBackground 方法,所以把这个粘贴到你的表单(窗口)

                  I think the only way to give that space a color is to override the OnPaintBackground method of the window, so just paste this on your form (window)

                  您还必须将外观属性更改为正常"

                  you must also change the Appearance Property to "Normal"

                  private void Form1_Load(object sender, EventArgs e)
                  {
                  
                  }
                  
                  protected override void OnPaintBackground(PaintEventArgs e)
                  {
                      base.OnPaintBackground(e);
                      Rectangle lasttabrect = tabControl1.GetTabRect(tabControl1.TabPages.Count - 1);
                      RectangleF emptyspacerect = new RectangleF(
                              lasttabrect.X + lasttabrect.Width + tabControl1.Left,
                              tabControl1.Top + lasttabrect.Y, 
                              tabControl1.Width - (lasttabrect.X + lasttabrect.Width), 
                              lasttabrect.Height);
                  
                      Brush b = Brushes.BlueViolet; // the color you want
                      e.Graphics.FillRectangle(b, emptyspacerect );
                  }
                  

                  对我来说效果很好

                  这篇关于如何更改 C# winforms 中未使用空间选项卡的背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何通过 Selenium 在 Chrome 上获取当前活动的标签 下一篇:Silverlight tabchanged 事件 - tabcontrol

                  相关文章

                  最新文章

                • <legend id='esOpS'><style id='esOpS'><dir id='esOpS'><q id='esOpS'></q></dir></style></legend>

                    <i id='esOpS'><tr id='esOpS'><dt id='esOpS'><q id='esOpS'><span id='esOpS'><b id='esOpS'><form id='esOpS'><ins id='esOpS'></ins><ul id='esOpS'></ul><sub id='esOpS'></sub></form><legend id='esOpS'></legend><bdo id='esOpS'><pre id='esOpS'><center id='esOpS'></center></pre></bdo></b><th id='esOpS'></th></span></q></dt></tr></i><div id='esOpS'><tfoot id='esOpS'></tfoot><dl id='esOpS'><fieldset id='esOpS'></fieldset></dl></div>

                      <small id='esOpS'></small><noframes id='esOpS'>

                      • <bdo id='esOpS'></bdo><ul id='esOpS'></ul>
                    1. <tfoot id='esOpS'></tfoot>