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

                  //--------------------------------------------------------------------------
                  /// <summary>
                  
          /// TabControl DrawItem時発生します。
                  
          /// </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 閱讀(449) 評論(0)  編輯  收藏 所屬分類: .Net
          主站蜘蛛池模板: 杭锦后旗| 嘉定区| 定陶县| 紫云| 杭州市| 松桃| 镇赉县| 确山县| 丰台区| 延庆县| 屯留县| 全椒县| 宿州市| 桂阳县| 济宁市| 龙陵县| 涟源市| 福贡县| 那坡县| 驻马店市| 普兰店市| 伊宁县| 綦江县| 张家港市| 阿克陶县| 彰化县| 临桂县| 广宗县| 眉山市| 伊金霍洛旗| 镇巴县| 寿阳县| 色达县| 黄骅市| 定南县| 肇庆市| 新龙县| 衡水市| 海兴县| 昔阳县| 酉阳|