当前位置: 首页>>代码示例>>C#>>正文


C# DataGridViewCellPaintingEventArgs.PaintContent方法代码示例

本文整理汇总了C#中System.Windows.Forms.DataGridViewCellPaintingEventArgs.PaintContent方法的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewCellPaintingEventArgs.PaintContent方法的具体用法?C# DataGridViewCellPaintingEventArgs.PaintContent怎么用?C# DataGridViewCellPaintingEventArgs.PaintContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.DataGridViewCellPaintingEventArgs的用法示例。


在下文中一共展示了DataGridViewCellPaintingEventArgs.PaintContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: board_CellPainting

        private void board_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            string number = "";

            // foreach(item c in List of items)
            if (_idc.Any(c => (number = c.Number) != "" && c.X == e.ColumnIndex && c.Y == e.RowIndex))
            {
                var r = new Rectangle(e.CellBounds.X, e.CellBounds.Y, e.CellBounds.Width, e.CellBounds.Height);
                e.Graphics.FillRectangle(Brushes.White, r);
                var f = new Font(e.CellStyle.Font.FontFamily, 7);
                e.Graphics.DrawString(number, f, Brushes.Black, r);
                e.PaintContent(e.ClipBounds);
                e.Handled = true;
            }
        }
开发者ID:Tens101010,项目名称:CrossWordPuzzle,代码行数:15,代码来源:Form1.cs

示例2: AddCustomCellStyle

        private void AddCustomCellStyle(DataGridViewCellPaintingEventArgs e)
        {
            // 绘制背景色
            using (LinearGradientBrush backbrush =
                new LinearGradientBrush(e.CellBounds,
                    ProfessionalColors.MenuItemPressedGradientBegin,
                    ProfessionalColors.MenuItemPressedGradientMiddle
                    , LinearGradientMode.Vertical))
            {

                Rectangle border = e.CellBounds;
                border.Width += 2;
                border.X -= 1;
                //填充绘制效果
                e.Graphics.FillRectangle(backbrush, border);
                //绘制Column、Row的Text信息
                e.PaintContent(e.CellBounds);
                //绘制边框
                ControlPaint.DrawBorder3D(e.Graphics, border, Border3DStyle.Etched);
            }
        }
开发者ID:shepherds126,项目名称:12306_Helper,代码行数:21,代码来源:formPassengersEdit.cs

示例3: drawColumnAndRow

 void drawColumnAndRow(DataGridViewCellPaintingEventArgs e)
 {
     // 绘制背景色
     using (LinearGradientBrush backbrush = new LinearGradientBrush(e.CellBounds, Color.Orange, Color.Orange, LinearGradientMode.Vertical))
     {
         Rectangle border = e.CellBounds;
         border.Width -= 1;
         //填充绘制效果
         e.Graphics.FillRectangle(backbrush, border);
         //绘制Column、Row的Text信息
         e.PaintContent(e.CellBounds);
         //绘制边框
         //ControlPaint.DrawBorder3D(e.Graphics, e.CellBounds, Border3DStyle.Flat);
         ControlPaint.DrawBorder(e.Graphics, e.CellBounds, Color.White, ButtonBorderStyle.Solid);
     }
 }
开发者ID:hacker-i,项目名称:NPControl,代码行数:16,代码来源:NPDataGridView.cs

示例4: DrawCellBackColor

    ///////////////////////////////////////////////////////////////////////////////
    // Eventhandler                                                              //
    ///////////////////////////////////////////////////////////////////////////////
    #region EVENTS

    ///////////////////////////////////////////////////////////////////////////////
    // Eventhandler for UI, Menu, Buttons, Toolbars etc.                         //
    ///////////////////////////////////////////////////////////////////////////////
    #region WINDOWSEVENTHANDLER
    #endregion //WINDOWSEVENTHANDLER

    ///////////////////////////////////////////////////////////////////////////////
    // Eventhandler for Custom Defined Events                                    //
    ///////////////////////////////////////////////////////////////////////////////
    #region CUSTOMEVENTHANDLER
    #endregion //CUSTOMEVENTHANDLER

    #endregion //EVENTS

    ///////////////////////////////////////////////////////////////////////////////
    // Methods and Eventhandling for Background tasks                            //
    ///////////////////////////////////////////////////////////////////////////////
    #region BACKGROUNDWORKER
    #endregion //BACKGROUNDWORKER

    ///////////////////////////////////////////////////////////////////////////////
    // Methods for doing main class job                                          //
    ///////////////////////////////////////////////////////////////////////////////
    #region PRIVATEMETHODS
    #endregion //PRIVATEMETHODS

    ///////////////////////////////////////////////////////////////////////////////
    // Small helping Methods                                                     //
    ///////////////////////////////////////////////////////////////////////////////
    #region HELPER
    #endregion //HELPER

    /// <summary>
    /// This method draws data cells with semitransparent background.
    /// Selected cells are drawn by default.
    /// </summary>
    /// <param name="e">A <see cref="DataGridViewCellPaintingEventArgs"/> with the event data.</param>
    private void DrawCellBackColor(DataGridViewCellPaintingEventArgs e)
    {
      if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected)
      {
        base.OnCellPainting(e);
        return;
      }

      using (SolidBrush fillBrush = new SolidBrush(Color.FromArgb(200,Color.White)))
      {
        using (Pen gridPenColor = new Pen(this.GridColor))
        {
          Rectangle rect1 = new Rectangle(e.CellBounds.Location, e.CellBounds.Size);
          Rectangle rect2 = new Rectangle(e.CellBounds.Location, e.CellBounds.Size);

          rect1.X -= 1;
          rect1.Y -= 1;

          rect2.Width -= 1;
          rect2.Height -= 1;

          // must draw border for grid scrolling horizontally 
          e.Graphics.DrawRectangle(gridPenColor, rect1);

          e.Graphics.FillRectangle(fillBrush, rect2);
        }
      }

      e.PaintContent(e.CellBounds);  // output cell text
      e.Handled = true;
    }
开发者ID:DeSciL,项目名称:Ogama,代码行数:73,代码来源:DataGridViewWithBackground.cs

示例5: DtgLogMessagesCellPainting

        /// <summary>
        /// Handles the CellPainting event of the <see cref="DataGridView"/>.
        /// </summary>
        private void DtgLogMessagesCellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            if (e.RowIndex >= mFilteredLogMessages.Count || e.RowIndex < 0)
              {
            return;
              }

              if ((e.State & DataGridViewElementStates.Visible) == DataGridViewElementStates.None)
              {
            return;
              }

              Color foreColor       = SystemColors.WindowText;
              Color backColor       = SystemColors.Window;
              Brush backgroundBrush = null;

              if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected)
              {
            foreColor       = SystemColors.HighlightText;
            backColor       = SystemColors.MenuHighlight;
            backgroundBrush = BrushCache.GetBrushFromColor(backColor);
              }
              else
              {
            switch (mFilteredLogMessages[e.RowIndex].Level)
            {
              case LogLevel.Trace:
            foreColor = Settings.Default.ForegroundColorTrace;
            backColor = Settings.Default.BackgroundColorTrace;
            backgroundBrush = BrushCache.GetBrushFromColor(backColor);
            break;
              case LogLevel.Debug:
            foreColor = Settings.Default.ForegroundColorDebug;
            backColor = Settings.Default.BackgroundColorDebug;
            backgroundBrush = BrushCache.GetBrushFromColor(backColor);
            break;
              case LogLevel.Info:
            foreColor = Settings.Default.ForegroundColorInfo;
            backColor = Settings.Default.BackgroundColorInfo;
            backgroundBrush = BrushCache.GetBrushFromColor(backColor);
            break;
              case LogLevel.Warning:
            foreColor = Settings.Default.ForegroundColorWarning;
            backColor = Settings.Default.BackgroundColorWarning;
            backgroundBrush = BrushCache.GetBrushFromColor(backColor);
            break;
              case LogLevel.Error:
            foreColor = Settings.Default.ForegroundColorError;
            backColor = Settings.Default.BackgroundColorError;
            backgroundBrush = BrushCache.GetBrushFromColor(backColor);
            break;
              case LogLevel.Fatal:
            foreColor = Settings.Default.ForegroundColorFatal;
            backColor = Settings.Default.BackgroundColorFatal;
            backgroundBrush = BrushCache.GetBrushFromColor(backColor);
            break;
            }
              }

              if (backgroundBrush != null)
              {
            e.Graphics.FillRectangle(
            backgroundBrush
              , e.CellBounds);

            if (e.ColumnIndex == 0)
            {
              // the first column may be an image.
              e.PaintContent(e.CellBounds);
            }
            else
            {
              TextRenderer.DrawText(
              e.Graphics
            , e.Value.ToString()
            , dtgLogMessages.DefaultCellStyle.Font
            , e.CellBounds
            , foreColor
            , backColor
            , TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter);
            }

            e.Graphics.DrawRectangle(
            SystemPens.ControlDark
              , e.CellBounds);

            e.Handled = true;
              }
        }
开发者ID:couchcoding,项目名称:Logbert,代码行数:92,代码来源:FrmLogWindow.cs

示例6: CellPaintFilter

        public static void CellPaintFilter(ILogPaintContext logPaintCtx, DataGridView gridView, DataGridViewCellPaintingEventArgs e, int lineNum, string line, HilightEntry entry)
        {

                e.Graphics.SetClip(e.CellBounds);
                if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected)
                {
                    Brush brush;
                    if (gridView.Focused)
                    {
                        brush = new SolidBrush(e.CellStyle.SelectionBackColor);
                    }
                    else
                    {
                        Color color = Color.FromArgb(255, 170, 170, 170);
                        brush = new SolidBrush(color);
                    }
                    e.Graphics.FillRectangle(brush, e.CellBounds);
                    brush.Dispose();
                }
                else
                {
                    Color bgColor = Color.White;
                    // paint direct filter hits with different bg color
                    //if (this.filterParams.SpreadEnabled && this.filterHitList.Contains(lineNum))
                    //{
                    //  bgColor = Color.FromArgb(255, 220, 220, 220);
                    //}
                    if (entry != null)
                    {
                        bgColor = entry.BackgroundColor;
                    }
                    e.CellStyle.BackColor = bgColor;
                    e.PaintBackground(e.ClipBounds, false);
                }

                if (DebugOptions.disableWordHighlight)
                {
                    e.PaintContent(e.CellBounds);
                }
                else
                {
                    PaintCell(logPaintCtx, e, gridView, false, entry);
                }

                if (e.ColumnIndex == 0)
                {
                    Bookmark bookmark = logPaintCtx.GetBookmarkForLine(lineNum);
                    if (bookmark != null)
                    {
                        Rectangle r = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6);
                        r = e.CellBounds;
                        r.Inflate(-2, -2);
                        Brush brush = new SolidBrush(logPaintCtx.BookmarkColor);
                        e.Graphics.FillRectangle(brush, r);
                        brush.Dispose();
                        if (bookmark.Text.Length > 0)
                        {
                            StringFormat format = new StringFormat();
                            format.LineAlignment = StringAlignment.Center;
                            format.Alignment = StringAlignment.Center;
                            Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0));
                            Font font = logPaintCtx.NormalFont; //TODO Zarunbal: Check if settings normal font is the right
                            e.Graphics.DrawString("!", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format);
                            font.Dispose();
                            brush2.Dispose();
                        }
                    }
                }

                e.Paint(e.CellBounds, DataGridViewPaintParts.Border);
                e.Handled = true;
        }
开发者ID:gspatace,项目名称:logexpert,代码行数:72,代码来源:PaintHelper.cs

示例7: CellPainting

        public static void CellPainting(ILogPaintContext logPaintCtx, DataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e)
        {
            if (rowIndex < 0 || e.ColumnIndex < 0)
            {
                e.Handled = false;
                return;
            }
            string line = logPaintCtx.GetLogLine(rowIndex);
            if (line != null)
            {
                HilightEntry entry = logPaintCtx.FindHilightEntry(line, true);
                e.Graphics.SetClip(e.CellBounds);
                if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected)
                {
                    Brush brush;
                    if (gridView.Focused)
                    {
                        brush = new SolidBrush(e.CellStyle.SelectionBackColor);
                    }
                    else
                    {
                        Color color = Color.FromArgb(255, 170, 170, 170);
                        brush = new SolidBrush(color);
                    }
                    e.Graphics.FillRectangle(brush, e.CellBounds);
                    brush.Dispose();
                }
                else
                {
                    Color bgColor = Color.White;
                    if (entry != null)
                    {
                        bgColor = entry.BackgroundColor;
                    }
                    e.CellStyle.BackColor = bgColor;
                    e.PaintBackground(e.ClipBounds, false);
                }

                if (DebugOptions.disableWordHighlight)
                {
                    e.PaintContent(e.CellBounds);
                }
                else
                {
                    PaintCell(logPaintCtx, e, gridView, false, entry);
                }

                if (e.ColumnIndex == 0)
                {
                    Bookmark bookmark = logPaintCtx.GetBookmarkForLine(rowIndex);
                    if (bookmark != null)
                    {
                        Rectangle r; // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6);
                        r = e.CellBounds;
                        r.Inflate(-2, -2);
                        Brush brush = new SolidBrush(logPaintCtx.BookmarkColor);
                        e.Graphics.FillRectangle(brush, r);
                        brush.Dispose();
                        if (bookmark.Text.Length > 0)
                        {
                            StringFormat format = new StringFormat();
                            format.LineAlignment = StringAlignment.Center;
                            format.Alignment = StringAlignment.Center;
                            Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0));
                            Font font = logPaintCtx.MonospacedFont;
                            e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height), format);
                            brush2.Dispose();
                        }
                    }
                }

                e.Paint(e.CellBounds, DataGridViewPaintParts.Border);
                e.Handled = true;
            }
        }
开发者ID:gspatace,项目名称:logexpert,代码行数:75,代码来源:PaintHelper.cs

示例8: patternHitsDataGridView_CellPainting

		private void patternHitsDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
		{
			if (this.currentList == null || e.RowIndex < 0)
				return;
			if (e.ColumnIndex == 1)
			{
				e.PaintBackground(e.CellBounds, false);
				int selCount = (this.patternArgs.endLine - this.patternArgs.startLine);
				int maxWeight = this.patternArgs.maxDiffInBlock * selCount + selCount;
				if (maxWeight > 0)
				{
					int width = (int)(((double)(int)e.Value / (double)maxWeight) * (double)e.CellBounds.Width);
					Rectangle rect = new Rectangle(e.CellBounds.X, e.CellBounds.Y, width, e.CellBounds.Height);
					int alpha = 90 + (int)(((double)(int)e.Value / (double)maxWeight) * (double)165);
					Color color = Color.FromArgb(alpha, 170, 180, 150);
					Brush brush = new SolidBrush(color);
					rect.Inflate(-2, -1);
					e.Graphics.FillRectangle(brush, rect);
					brush.Dispose();
				}
				e.PaintContent(e.CellBounds);
				e.Handled = true;
			}
			else
			{
				DataGridView gridView = (DataGridView)sender;
				int rowIndex = GetLineForHitGrid(e.RowIndex);
				PaintHelper.CellPainting(logWindow,gridView, rowIndex, e); //TODO Zarunbal: check if it works!
			}
		}
开发者ID:gspatace,项目名称:logexpert,代码行数:30,代码来源:PatternWindow.cs

示例9: drawColumnRow

        /// <summary>
        /// Column和RowHeader绘制
        /// </summary>
        /// <param name="e"></param>
        void drawColumnRow(DataGridViewCellPaintingEventArgs e)
        {
            Rectangle border = e.CellBounds;
            Color clr = Color.FromArgb(247, 247, 247),
                  clr2 = Color.FromArgb(214, 214, 214);
            if (e.RowIndex % 2 == 0) clr = Color.FromArgb(241, 241, 241);

            using (Brush br = new SolidBrush(clr)) {
                e.Graphics.FillRectangle(br, border);
            }

            border.Width += 1;
            e.Graphics.DrawLine(new Pen(clr2, 1),
                new PointF(border.Left, border.Bottom - 1),
                new PointF(border.Right, border.Bottom - 1)
                );
            if (e.ColumnIndex == 0) {
                //左线
                e.Graphics.DrawLine(new Pen(clr2, 1), new PointF(border.Left, border.Top), new PointF(border.Left, border.Bottom));
            }
            if (e.ColumnIndex == this.Columns.Count - 1) {
                //右线
                e.Graphics.DrawLine(new Pen(clr2, 1), new PointF(border.Right - 2, border.Top), new PointF(border.Right - 2, border.Bottom));
            }

            e.PaintContent(e.CellBounds);
        }
开发者ID:jango2015,项目名称:SendEmail,代码行数:31,代码来源:DBGridView.cs

示例10: dgv_CellPainting

      private static void dgv_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
      {
         //Color mLinearColor1 = Color.FromArgb(252, 248, 239);
         //Color mLinearColor2 = Color.FromArgb(247, 230, 192);
         Color mLinearColor1 = Color.FromArgb(248, 250, 251);
         Color mLinearColor2 = Color.FromArgb(248, 250, 251);
         Color mGridColor = Color.FromArgb(111, 169, 217); //网格线的颜色
         //控件的焦点框颜色 

         Rectangle Rect = new Rectangle(e.CellBounds.X - 1, e.CellBounds.Y, e.CellBounds.Width, e.CellBounds.Height - 1);
         LinearGradientBrush LinearGradientBrush = new LinearGradientBrush(Rect, mLinearColor1, mLinearColor2,
                                                                           LinearGradientMode.Vertical);

         try
         {
            if (e.RowIndex == -1 || e.ColumnIndex == -1)
            {
               e.Graphics.FillRectangle(LinearGradientBrush, Rect);
               e.Graphics.DrawRectangle(new Pen(mGridColor), Rect);
               e.PaintContent(e.CellBounds);
               e.Handled = true;
            }
         }
         catch
         {
         }
      }
开发者ID:hubuUniversity,项目名称:demo,代码行数:27,代码来源:DataGridViewBll.cs

示例11: dataGridView_CellPainting

 private void dataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
 {
     if (e.RowIndex == -1)
     {
         if (e.Value == null)
             return;
         var langName = e.Value.ToString().ToLower().Replace(".resx", "");
         var indexLastDot = langName.LastIndexOf('.');
         e.Paint(e.CellBounds, DataGridViewPaintParts.All & ~DataGridViewPaintParts.ContentForeground);
         if (indexLastDot != -1)
         {
             try
             {
                 langName = langName.Substring(++indexLastDot);
                 CultureInfo culture = new CultureInfo(langName);
                 RegionInfo region = new RegionInfo(culture.TextInfo.LCID);
                 Image flag = Image.FromFile(Path.Combine(PATH_FLAGS, string.Format("{0}.png", region.TwoLetterISORegionName)));
                 Rectangle flagRect = new Rectangle(e.CellBounds.Location, flag.Size);
                 flagRect.Offset(4, 10);
                 e.Graphics.DrawImage(flag, flagRect);
             }
             catch (Exception)
             {
             }
         }
         e.PaintContent(e.CellBounds);
         e.Handled = true;
     }
     else
     {
         if (e.RowIndex % 2 == 0)
         {
             //int R = e.CellStyle.BackColor.R + BACK_ALT > 255 ? e.CellStyle.BackColor.R - BACK_ALT : e.CellStyle.BackColor.R + BACK_ALT;
             //int G = e.CellStyle.BackColor.G + BACK_ALT > 255 ? e.CellStyle.BackColor.G - BACK_ALT : e.CellStyle.BackColor.G + BACK_ALT;
             //int B = e.CellStyle.BackColor.B + BACK_ALT > 255 ? e.CellStyle.BackColor.B - BACK_ALT : e.CellStyle.BackColor.B + BACK_ALT;
             int R = e.CellStyle.BackColor.R - BACK_ALT < 0 ? e.CellStyle.BackColor.R : e.CellStyle.BackColor.R - BACK_ALT;
             int G = e.CellStyle.BackColor.G - BACK_ALT < 0 ? e.CellStyle.BackColor.G : e.CellStyle.BackColor.G - BACK_ALT;
             int B = e.CellStyle.BackColor.B - BACK_ALT < 0 ? e.CellStyle.BackColor.B : e.CellStyle.BackColor.B - BACK_ALT;
             e.CellStyle.BackColor = Color.FromArgb(e.CellStyle.BackColor.A, R, G, B);
         }
     }
 }
开发者ID:koffeinfrei,项目名称:simpleresxeditor2,代码行数:42,代码来源:FrmMain.cs

示例12: board_CellPainting

        private void board_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            foreach (var CellValue in CellValues.Values)
            {
                if (CellValue.GetXColumnCoordinate() == e.ColumnIndex && CellValue.GetYRowCoordinate() == e.RowIndex)
                {
                    //the black background
                    Rectangle rectangle2 = new Rectangle(e.CellBounds.X, e.CellBounds.Y, e.CellBounds.Width, e.CellBounds.Height);
                    e.Graphics.FillRectangle(Brushes.Black, rectangle2);

                    // the white foreground
                    Rectangle rectangle = new Rectangle(e.CellBounds.X+1 , e.CellBounds.Y+1 , e.CellBounds.Width-2, e.CellBounds.Height-2);
                    e.Graphics.FillRectangle(Brushes.White, rectangle);
                    Font f = new Font(e.CellStyle.Font.FontFamily, 7);

                    string StringToPrint = "";

                    if (CellValue.GetLetterMultiplier() != 1 && CellValue.GetLetterMultiplier() != FIRST_INDEX)
                    {
                        StringToPrint += "L " + CellValue.GetLetterMultiplier().ToString() + " ";
                    }

                    if (CellValue.GetWordMultiplier() != 1 && CellValue.GetWordMultiplier() != FIRST_INDEX)
                    {
                        StringToPrint += "W " + CellValue.GetWordMultiplier().ToString();
                    }

                    e.Graphics.DrawString(StringToPrint, f, Brushes.Black, rectangle);
                    e.PaintContent(e.ClipBounds);
                    e.Handled = true;

                }
            }
        }
开发者ID:peku33,项目名称:ScrabbleSolver,代码行数:34,代码来源:GameForm.cs

示例13: OnCellPainting


//.........这里部分代码省略.........
                    }
                    else
                    {
                        bt = ct.RowPressedBackground;
                        borderColor = ct.RowPressedBorder;
                    }
                }
                else if (m_MouseOverRowIndex == e.RowIndex)
                {
                    bt = ct.RowMouseOverBackground;
                    borderColor = ct.RowMouseOverBorder;
                }

                DisplayHelp.FillRectangle(g, r, bt);
                // Paint border
                using (Pen p = new Pen(borderColor))
                {
                    g.DrawLine(p, r.Right - 1, r.Y, r.Right - 1, r.Bottom - 1);

                    if (m_SelectedRowIndex == e.RowIndex + 1 && enabled)
                    {
                        Color bc = ct.RowSelectedBorder;
                        if (m_MouseDownRowIndex == e.RowIndex  + 1)
                            bc = ct.RowPressedBorder;
                        else if (m_MouseOverRowIndex == e.RowIndex + 1)
                            bc = ct.RowSelectedMouseOverBorder;
                        using (Pen p2 = new Pen(bc))
                            g.DrawLine(p2, r.X, r.Bottom - 1, r.Right - 1, r.Bottom - 1);
                    }
                    else
                        g.DrawLine(p, r.X, r.Bottom - 1, r.Right - 1, r.Bottom - 1);
                }

                e.PaintContent(r);
            }
            else if (e.RowIndex == -1)
            {
                // Determine Colors
                if (m_MouseDownColumnHeader == e.ColumnIndex)
                {
                    bt = ct.ColumnHeaderPressedBackground;
                    borderColor = ct.ColumnHeaderPressedBorder;
                }
                else if (m_MouseOverColumnHeader == e.ColumnIndex)
                {
                    if (m_HighlightSelectedColumnHeaders && (displayIndex >= 0 && e.ColumnIndex >= 0 && (m_ColumnSelectionState.Length > displayIndex && m_ColumnSelectionState[displayIndex].Selected || this.Columns[e.ColumnIndex].Selected)))
                    {
                        bt = ct.ColumnHeaderSelectedMouseOverBackground;
                        borderColor = ct.ColumnHeaderSelectedMouseOverBorder;
                    }
                    else
                    {
                        bt = ct.ColumnHeaderMouseOverBackground;
                        borderColor = ct.ColumnHeaderMouseOverBorder;
                    }
                }
                else if (!m_HighlightSelectedColumnHeaders)
                {
                    bt = ct.ColumnHeaderNormalBackground;
                    borderColor = ct.ColumnHeaderNormalBorder;
                }
                else if (displayIndex >= 0 && e.ColumnIndex >= 0 && (m_ColumnSelectionState.Length > displayIndex && m_ColumnSelectionState[displayIndex].Selected || this.Columns[e.ColumnIndex].Selected) && enabled)
                {
                    bt = ct.ColumnHeaderSelectedBackground;
                    borderColor = ct.ColumnHeaderSelectedBorder;
                }
开发者ID:huamanhtuyen,项目名称:VNACCS,代码行数:67,代码来源:DataGridViewX.cs

示例14: DataGridView_CellPainting

        private void DataGridView_CellPainting(object sender,
            DataGridViewCellPaintingEventArgs e)
        {
            if (e.RowIndex == -1 && ColumnHeaderBackgroundImage != null)
            {
                int x = e.CellBounds.X;
                int y = e.CellBounds.Y;
                int width = e.CellBounds.Width;
                int height = e.CellBounds.Height;

                TextureBrush brush = new TextureBrush(ColumnHeaderBackgroundImage);

                e.Graphics.FillRectangle(brush, new Rectangle(x, y, width, height));

                #region 边框

                //Pen borderPen = new Pen(Color.FromArgb(190, 190, 190));//边框颜色

                ////画表头边框
                //if (e.ColumnIndex == 0)
                //{
                //    e.Graphics.DrawRectangle(borderPen,
                //        new Rectangle(x, y + 1, width - 1, height - 2));
                //}
                //else
                //{
                //    e.Graphics.DrawRectangle(borderPen,
                //        new Rectangle(x - 1, y + 1, width, height - 2));
                //}

                #endregion

                e.PaintContent(e.CellBounds);
                e.Handled = true;
            }
        }
开发者ID:wxll1120,项目名称:c585b99f,代码行数:36,代码来源:DataGridView.cs

示例15: OnCellPainting

        protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e)
        {
            base.OnCellPainting(e);
            if (e.ColumnIndex == -1 && e.RowIndex == -1)
            {
                using (LinearGradientBrush brush = new LinearGradientBrush(e.CellBounds, Color.FromArgb(169, 169, 169),
                    Color.FromArgb(169, 169, 169), LinearGradientMode.ForwardDiagonal))
                {
                    e.Graphics.FillRectangle(brush, e.CellBounds);
                    Rectangle border = e.CellBounds;
                    border.Offset(new Point(-1, -1));
                    Rectangle innerBorder = e.CellBounds;
                    Brush innerBorderBrush = new SolidBrush(Color.FromArgb(212, 212, 212));
                    Pen innerPen = new Pen(innerBorderBrush);

                    Brush bottomBorderBrush = new SolidBrush(Color.FromArgb(112, 112, 112));
                    Pen bottomPen = new Pen(bottomBorderBrush);

                    Brush borderBrush = new SolidBrush(Color.FromArgb(56, 56, 56));
                    Pen pen = new Pen(borderBrush);

                    e.Graphics.DrawRectangle(pen, border);
                    e.Graphics.DrawLine(innerPen, new Point(border.X + 1, border.Y), new Point(border.X + 1, border.Y + border.Height - 1));

                    e.Graphics.DrawLine(bottomPen, new Point(border.X + border.Width - 1, border.Y), new Point(border.X + border.Width - 1, border.Y + border.Height - 1));

                    e.Graphics.DrawLine(innerPen, new Point(border.X + 1, border.Y + 1), new Point(border.X + border.Width - 2, border.Y + 1));

                    e.Graphics.DrawLine(bottomPen, new Point(border.X + 2, border.Y + border.Height - 1), new Point(border.X + border.Width - 2, border.Y + border.Height - 1));
                }
                e.PaintContent(e.CellBounds);
                e.Handled = true;
            }
            else if (e.RowIndex == -1)
            {
                //标题行
                using (LinearGradientBrush brush = new LinearGradientBrush(e.CellBounds, Color.FromArgb(169, 169, 169),
                    Color.FromArgb(169, 169, 169), LinearGradientMode.Vertical))
                {
                    e.Graphics.FillRectangle(brush, e.CellBounds);
                    Rectangle border = e.CellBounds;
                    border.Offset(new Point(-1, -1));

                    Rectangle innerBorder = e.CellBounds;
                    Brush innerBorderBrush = new SolidBrush(Color.FromArgb(212, 212, 212));
                    Pen innerPen = new Pen(innerBorderBrush);

                    Brush bottomBorderBrush = new SolidBrush(Color.FromArgb(112, 112, 112));
                    Pen bottomPen = new Pen(bottomBorderBrush);

                    Brush borderBrush = new SolidBrush(Color.FromArgb(56, 56, 56));
                    Pen pen = new Pen(borderBrush);

                    e.Graphics.DrawRectangle(pen, border);
                    e.Graphics.DrawLine(innerPen, new Point(border.X + 1, border.Y), new Point(border.X + 1, border.Y + border.Height - 1));

                    e.Graphics.DrawLine(bottomPen, new Point(border.X + border.Width - 1, border.Y), new Point(border.X + border.Width - 1, border.Y + border.Height - 1));

                    e.Graphics.DrawLine(innerPen, new Point(border.X + 1, border.Y + 1), new Point(border.X + border.Width - 2, border.Y + 1));

                    e.Graphics.DrawLine(bottomPen, new Point(border.X + 2, border.Y + border.Height - 1), new Point(border.X + border.Width - 2, border.Y + border.Height - 1));

                }
                e.PaintContent(e.CellBounds);
                e.Handled = true;
            }
            else if (e.ColumnIndex == -1)
            {
                //标题列
                using (LinearGradientBrush brush = new LinearGradientBrush(e.CellBounds, Color.FromArgb(169, 169, 169),
                    Color.FromArgb(169, 169, 169), LinearGradientMode.Horizontal))
                {
                    e.Graphics.FillRectangle(brush, e.CellBounds);
                    Rectangle border = e.CellBounds;
                    border.Offset(new Point(-1, -1));

                    Rectangle innerBorder = e.CellBounds;
                    Brush innerBorderBrush = new SolidBrush(Color.FromArgb(212, 212, 212));
                    Pen innerPen = new Pen(innerBorderBrush);

                    Brush bottomBorderBrush = new SolidBrush(Color.FromArgb(112, 112, 112));
                    Pen bottomPen = new Pen(bottomBorderBrush);

                    Brush borderBrush = new SolidBrush(Color.FromArgb(56, 56, 56));
                    Pen pen = new Pen(borderBrush);

                    e.Graphics.DrawRectangle(pen, border);
                    e.Graphics.DrawLine(innerPen, new Point(border.X + 1, border.Y), new Point(border.X + 1, border.Y + border.Height - 1));

                    e.Graphics.DrawLine(bottomPen, new Point(border.X + border.Width - 1, border.Y), new Point(border.X + border.Width - 1, border.Y + border.Height - 1));

                    e.Graphics.DrawLine(innerPen, new Point(border.X + 1, border.Y + 1), new Point(border.X + border.Width - 2, border.Y + 1));

                    e.Graphics.DrawLine(bottomPen, new Point(border.X + 2, border.Y + border.Height - 1), new Point(border.X + border.Width - 2, border.Y + border.Height - 1));
                }
                e.PaintContent(e.CellBounds);
                e.Handled = true;
            }
        }
开发者ID:hacsonchen,项目名称:POCKET,代码行数:99,代码来源:DataGridViewPlus.cs


注:本文中的System.Windows.Forms.DataGridViewCellPaintingEventArgs.PaintContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。