或許,我會(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 閱讀(451) 評(píng)論(0)  編輯  收藏 所屬分類: .Net
          主站蜘蛛池模板: 花莲市| 肇州县| 长顺县| 金湖县| 宣武区| 聂拉木县| 黑龙江省| 庆云县| 郸城县| 关岭| 延长县| 新田县| 葵青区| 武清区| 嘉峪关市| 根河市| 鸡西市| 灵台县| 镇巴县| 浦县| 克什克腾旗| 扶绥县| 和林格尔县| 桃园县| 贺州市| 定兴县| 北碚区| 虎林市| 黔江区| 兴海县| 涡阳县| 博罗县| 梁河县| 望奎县| 澜沧| 三河市| 怀安县| 乐东| 阳城县| 车致| 米林县|