或許,我會(huì)成為一名畫(huà)家。。。
          this.tabContents.DrawMode = TabDrawMode.OwnerDrawFixed;

                  //--------------------------------------------------------------------------
                  /// <summary>
                  
          /// TabControl DrawItem時(shí)発生します。
                  
          /// </summary>
                  
          /// <param name="sender"></param>
                  
          /// <param name="e"></param>
                  //--------------------------------------------------------------------------
                  private void tabContents_DrawItem(object sender, DrawItemEventArgs e)
                  {
                      SolidBrush pink = new SolidBrush(Color.Pink);
                      SolidBrush ws = new SolidBrush(Color.LightGray);
                      SolidBrush white = new SolidBrush(Color.White);
                      SolidBrush black = new SolidBrush(Color.Black);
                      StringFormat sf = new StringFormat();
                      Pen pen = new Pen(Color.Gray);
                      sf.Alignment = StringAlignment.Center;

                      string text = tabContents.TabPages[e.Index].Text;
                      Rectangle rect = tabContents.GetTabRect(e.Index);
                      Rectangle rectSelected = new Rectangle(rect.X - 3, rect.Y - 3, rect.Width, rect.Height + 3);
                      if (text == "メモ" && hasMemo)
                          e.Graphics.FillRectangle(pink, rect);
                      else
                      {
                          if (tabContents.SelectedIndex == e.Index)
                              e.Graphics.FillRectangle(white, rectSelected);
                          else
                              e.Graphics.FillRectangle(ws, rect);
                      }

                      Rectangle rectText = new Rectangle(rect.X, rect.Y + 3, rect.Width, rect.Height + 3);
                      e.Graphics.DrawString(text, new Font("MS UI Gothic", 9), black, rectText, sf);

                      Point p1 = new Point(rect.X, rect.Y);
                      Point p2 = new Point(rect.X, rect.Y + rect.Height);
                      e.Graphics.DrawLine(pen, p1, p2);
                      p1 = new Point(rect.X + rect.Width, rect.Y);
                      p2 = new Point(rect.X + rect.Width, rect.Y + rect.Height);
                      e.Graphics.DrawLine(pen, p1, p2);
                      p1 = new Point(rect.X, rect.Y);
                      p2 = new Point(rect.X + rect.Width, rect.Y);
                      e.Graphics.DrawLine(pen, p1, p2);
                  }
          posted on 2016-04-18 16:51 Ying-er 閱讀(443) 評(píng)論(0)  編輯  收藏 所屬分類: .Net
          主站蜘蛛池模板: 勐海县| 抚顺市| 连城县| 巴中市| 上蔡县| 德令哈市| 丹巴县| 南木林县| 玉田县| 那曲县| 景泰县| 阿拉尔市| 关岭| 铜川市| 永定县| 张家川| 宁陵县| 东光县| 吴川市| 南通市| 左贡县| 宿州市| 东乡族自治县| 定陶县| 马尔康县| 泰兴市| 宜城市| 柞水县| 武安市| 高平市| 抚顺市| 怀仁县| 嘉兴市| 漯河市| 绥江县| 定安县| 芦山县| 什邡市| 武夷山市| 金乡县| 胶南市|