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


C# DataGridViewPaintParts类代码示例

本文整理汇总了C#中DataGridViewPaintParts的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewPaintParts类的具体用法?C# DataGridViewPaintParts怎么用?C# DataGridViewPaintParts使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Paint

 protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
 {
     var buttonRectangle = new Rectangle(cellBounds.X + 2, cellBounds.Y + 2, cellBounds.Width - 4, cellBounds.Height - 4);
     base.Paint(graphics, clipBounds, buttonRectangle, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
     var imageRectangle = new Rectangle(cellBounds.X + 6, cellBounds.Y + 6, _detailImage.Width, _detailImage.Height);
     graphics.DrawImage(_detailImage, imageRectangle);
 }
开发者ID:pragmasolutions,项目名称:Libreria,代码行数:7,代码来源:DetailsColumn.cs

示例2: Paint

        protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            try
            {
                int progressVal = (int)value;
                float percentage = ((float)progressVal / 100.0f); // Need to convert to float before division; otherwise C# returns int which is 0 for anything but 100%.
                Brush backColorBrush = new SolidBrush(cellStyle.BackColor);
                Brush foreColorBrush = new SolidBrush(cellStyle.ForeColor);
                // Draws the cell grid
                base.Paint(g, clipBounds, cellBounds,
                 rowIndex, cellState, value, formattedValue, errorText,
                 cellStyle, advancedBorderStyle, (paintParts & ~DataGridViewPaintParts.ContentForeground));
                if (percentage > 0.0)
                {
                    // Draw the progress bar and the text
                    g.FillRectangle(new SolidBrush(Color.FromArgb(203, 235, 108)), cellBounds.X + 2, cellBounds.Y + 2, Convert.ToInt32((percentage * cellBounds.Width - 4)), cellBounds.Height - 4);
                    g.DrawString(progressVal.ToString() + "%", cellStyle.Font, foreColorBrush, cellBounds.X + (cellBounds.Width / 2) - 5, cellBounds.Y + 2);

                }
                else
                {
                    g.DrawString("Ожидание...", cellStyle.Font, foreColorBrush, cellBounds.X + (cellBounds.Width / 2) - 25, cellBounds.Y + 2);
                }
            }
            catch (Exception e) { }
        }
开发者ID:tatar1nro,项目名称:KKM_Trash,代码行数:26,代码来源:dataProgress.cs

示例3: Paint

        protected override void Paint(Graphics graphics,
            Rectangle clipBounds, Rectangle cellBounds, int rowIndex,
            DataGridViewElementStates elementState, object value,
            object formattedValue, string errorText,
            DataGridViewCellStyle cellStyle,
            DataGridViewAdvancedBorderStyle advancedBorderStyle,
            DataGridViewPaintParts paintParts)
        {
            // The button cell is disabled, so paint the border,
            // background, and disabled button for the cell.
            if (!this.enabledValue)
            {
                // Draw the cell background, if specified.
                if ((paintParts & DataGridViewPaintParts.Background) ==
                    DataGridViewPaintParts.Background)
                {
                    SolidBrush cellBackground =
                    new SolidBrush(cellStyle.BackColor);
                    graphics.FillRectangle(cellBackground, cellBounds);
                    cellBackground.Dispose();
                }

                // Draw the cell borders, if specified.
                if ((paintParts & DataGridViewPaintParts.Border) ==
                    DataGridViewPaintParts.Border)
                {
                    PaintBorder(graphics, clipBounds, cellBounds, cellStyle,
                        advancedBorderStyle);
                }

                // Calculate the area in which to draw the button.
                Rectangle buttonArea = cellBounds;
                Rectangle buttonAdjustment =
                    this.BorderWidths(advancedBorderStyle);
                buttonArea.X += buttonAdjustment.X;
                buttonArea.Y += buttonAdjustment.Y;
                buttonArea.Height -= buttonAdjustment.Height;
                buttonArea.Width -= buttonAdjustment.Width;

                // Draw the disabled button.
                ButtonRenderer.DrawButton(graphics, buttonArea, PushButtonState.Disabled);

                // Draw the disabled button text.
                if (this.FormattedValue is String)
                {
                    TextRenderer.DrawText(graphics,
                        (string)this.FormattedValue,
                        this.DataGridView.Font,
                        buttonArea, enabledValue ? SystemColors.ControlText : SystemColors.GrayText);
                }
            }
            else
            {
                // The button cell is enabled, so let the base class
                // handle the painting.
                base.Paint(graphics, clipBounds, cellBounds, rowIndex,
                    elementState, value, formattedValue, errorText,
                   cellStyle, advancedBorderStyle, paintParts);
            }
        }
开发者ID:Diullei,项目名称:Storm,代码行数:60,代码来源:VSintegration.cs

示例4: Paint

        protected override void Paint(Graphics g, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            try
            {
                int progressVal = (int)value;
                float percentage = ((float)progressVal / 100.0f); // Need to convert to float before division; otherwise C# returns int which is 0 for anything but 100%.

                // Draws the cell grid
                base.Paint(g, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, (paintParts & ~DataGridViewPaintParts.ContentForeground));

                // Draw the progress bar and the text
                g.FillRectangle(new SolidBrush(Color.FromArgb(8, 142, 6)), cellBounds.X + 2, cellBounds.Y + 2, Convert.ToInt32((percentage * cellBounds.Width - 4)), cellBounds.Height - 4);

                string text = Value.ToString() + "%";
                Font f = cellStyle.Font;

                SizeF len = g.MeasureString(text, f);

                SolidBrush foreColor = new SolidBrush(cellStyle.ForeColor);

                if (DataGridView.Rows[rowIndex].Selected)
                    foreColor = new SolidBrush(cellStyle.SelectionForeColor);

                Point location = new Point(Convert.ToInt32(cellBounds.X + ((cellBounds.Width / 2) - len.Width / 2)), Convert.ToInt32(cellBounds.Y + ((cellBounds.Height / 2) - len.Height / 2)));
                g.DrawString(text, f, foreColor, location);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error painting cell");
            }
        }
开发者ID:SteveMoody73,项目名称:Amleto,代码行数:31,代码来源:DataGridViewProgressCell.cs

示例5: Paint

        protected override void Paint(Graphics g, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            int progressVal = 0;
            string label = String.Empty;

            // get progress values
            if (value != null && value.GetType() == typeof(ProgressState))
            {
                ProgressState s = (ProgressState)value;
                progressVal = s.CurrentValue;
                label = s.CurrentState;
                if (s.ShowProgressBar == false || String.IsNullOrEmpty(label) == false)
                    progressVal = 0;
                if (s.HasError)
                    this.ErrorText = s.ErrorText;
            }

            // Draws the cell grid
            base.Paint(g, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, (paintParts & ~DataGridViewPaintParts.ContentForeground));

            // draw progress bar
            float percentage = ((float)progressVal / 100.0f); // Need to convert to float before division; otherwise C# returns int which is 0 for anything but 100%.
            if (percentage > 0.0)
            {
                using (Brush highlightBrush = new SolidBrush(SystemColors.Highlight))
                    g.FillRectangle(highlightBrush, cellBounds.X + 2, cellBounds.Y + 2, Convert.ToInt32((percentage * cellBounds.Width - 4)), cellBounds.Height - 4);
            }

            // draw text
            if (String.IsNullOrEmpty(label) == false)
            {
                using (Brush foreColorBrush = new SolidBrush(cellStyle.ForeColor))
                    g.DrawString(label, cellStyle.Font, foreColorBrush, cellBounds.X + 6, cellBounds.Y + 4);
            }
        }
开发者ID:johnreilly,项目名称:tracm,代码行数:35,代码来源:ProgressColumn.cs

示例6: Paint

        protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            var fillRectangle = new Rectangle(cellBounds.X, cellBounds.Y, cellBounds.Width - 1, cellBounds.Height - 1);
            var stringRectangle = new Rectangle(cellBounds.X + 5, cellBounds.Y + 3, cellBounds.Width - 8, cellBounds.Height - 8);
            graphics.SmoothingMode = SmoothingMode.AntiAlias;
            graphics.FillRectangle(new SolidBrush(Color.FromArgb(215, 228, 242)),
                                   fillRectangle);
            graphics.DrawLine(new Pen(Color.FromArgb(153, 180, 209), 1),
                              new Point(cellBounds.X + cellBounds.Width - 1, cellBounds.Y),
                              new Point(cellBounds.X + cellBounds.Width - 1, cellBounds.Y + cellBounds.Height - 1));
            graphics.DrawLine(new Pen(Color.FromArgb(153, 180, 209), 1),
                              new Point(cellBounds.X, cellBounds.Y + cellBounds.Height - 1),
                              new Point(cellBounds.X + cellBounds.Width - 1, cellBounds.Y + cellBounds.Height - 1));
            //var pen = new Pen(new LinearGradientBrush(new Rectangle(1, 1, 1, 1), 
            //                  Color.FromArgb(0, 0, 0), 
            //                  Color.FromArgb(200, 200, 200), 
            //                  LinearGradientMode.Horizontal))
            //{
            //    DashCap = DashCap.Round,
            //    Width = 1
            //};

            //graphics.DrawLine(pen,
            //                 new Point(cellBounds.X + 7, cellBounds.Y + 7),
            //                 new Point(cellBounds.X + cellBounds.Width - 7, cellBounds.Y + cellBounds.Height - 7));
            //graphics.DrawLine(pen,
            //                 new Point(cellBounds.X + cellBounds.Width - 7, cellBounds.Y + 7),
            //                 new Point(cellBounds.X + 7, cellBounds.Y + cellBounds.Height - 7));
            graphics.DrawString("X",
                                new Font("Comic Sans MS", 9.0f, FontStyle.Regular),
                                new SolidBrush(Color.FromArgb(0, 0, 0)),
                                stringRectangle);
        }
开发者ID:sscctech,项目名称:ServiceBusExplorer,代码行数:33,代码来源:DataGridViewDeleteButtonCell.cs

示例7: Paint

        protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            // the base Paint implementation paints the check box
            base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);

            // Get the check box bounds: they are the content bounds
            Rectangle contentBounds = this.GetContentBounds(rowIndex);

            // Compute the location where we want to paint the string.
            Point stringLocation = new Point();

            // Compute the Y.
            // NOTE: the current logic does not take into account padding.
            stringLocation.Y = cellBounds.Y + 2;

            // Compute the X.
            // Content bounds are computed relative to the cell bounds
            // - not relative to the DataGridView control.
            stringLocation.X = cellBounds.X + contentBounds.Right + 2;

            // Paint the string.
            if (this.Label == null)
            {
                DataGridViewCheckBoxWithLabelColumn col = (DataGridViewCheckBoxWithLabelColumn) this.OwningColumn;
                this.label = col.Label;
            }

            graphics.DrawString(this.Label, Control.DefaultFont, System.Drawing.Brushes.Red, stringLocation);
        }
开发者ID:osbeorn,项目名称:fireDeptFeesTool,代码行数:29,代码来源:DataGridViewCheckBoxWithLabelColumn.cs

示例8: Paint

        protected override void Paint(Graphics graphics,
            Rectangle clipBounds,
            Rectangle cellBounds,
            int rowIndex,
            DataGridViewElementStates cellState,
            object value,
            object formattedValue,
            string errorText,
            DataGridViewCellStyle cellStyle,
            DataGridViewAdvancedBorderStyle advancedBorderStyle,
            DataGridViewPaintParts paintParts)
        {
            if (this.DataGridView == null)
            {
                return;
            }

            // First paint the borders and background of the cell.
            base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle,
                       paintParts & ~(DataGridViewPaintParts.ErrorIcon | DataGridViewPaintParts.ContentForeground));

            IRulesBoxLine myLine = Value as IRulesBoxLine;
            myLine.Selected = this.Selected;
            myLine.Paint(graphics, cellStyle.Font, cellBounds.Left, cellBounds.Top);
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:25,代码来源:DataGridViewRulesBoxCell.cs

示例9: Paint

    protected override void Paint(Graphics graphics, Rectangle clipBounds,
        Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState,
        object value, object formattedValue, string errorText,
        DataGridViewCellStyle cellStyle,
        DataGridViewAdvancedBorderStyle advancedBorderStyle,
        DataGridViewPaintParts paintParts)
    {
      if (Columns.Count > rowIndex)
      {
        Column c = Columns[rowIndex];
        if (c.PrimaryKey)
        {
          Bitmap bmp = rowIndex == DataGridView.CurrentRow.Index ?
              Resources.ArrowKey : Resources.Key;
          bmp.MakeTransparent();
          paintParts &= ~DataGridViewPaintParts.ContentBackground;
          base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState,
              value, formattedValue, errorText, cellStyle, advancedBorderStyle,
              paintParts);
          Rectangle r = cellBounds;
          r.Offset(bmp.Width / 2, bmp.Height / 2);
          r.Width = bmp.Width;
          r.Height = bmp.Height;
          graphics.DrawImage(bmp, r);
          return;
        }
      }

      base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState,
          value, formattedValue, errorText, cellStyle, advancedBorderStyle,
          paintParts);
    }
开发者ID:jimmy00784,项目名称:mysql-connector-net,代码行数:32,代码来源:MyDataGridViewRowHeaderCell.cs

示例10: Paint

        protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            if (Image != null)
            {
                base.Paint(graphics, clipBounds,
                           new Rectangle(cellBounds.X + Image.Width, cellBounds.Y, cellBounds.Width - Image.Height,cellBounds.Height),
                           rowIndex, cellState, value, formattedValue,errorText, cellStyle, advancedBorderStyle, paintParts);

                if ((cellState & DataGridViewElementStates.Selected) != 0)
                {
                    graphics.FillRectangle(
                        new SolidBrush(this.DataGridView.DefaultCellStyle.SelectionBackColor)
                        , cellBounds.X, cellBounds.Y, Image.Width, cellBounds.Height);
                }
                else
                {
                    graphics.FillRectangle(new SolidBrush(this.DataGridView.DefaultCellStyle.BackColor),
                                           cellBounds.X, cellBounds.Y, Image.Width, cellBounds.Height);
                }
                graphics.DrawImage(Image, cellBounds.X, cellBounds.Y+2, Image.Width,
                                         Math.Min(Image.Height,cellBounds.Height));

            }
            else
            {
                base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
            }
        }
开发者ID:ChrisH4rding,项目名称:xenadmin,代码行数:28,代码来源:DataGridViewTextAndImageCell.cs

示例11: Paint

        protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            try
            {
                int progressVal = (int)value;
                if(progressVal < 0) progressVal = 0;
                if(progressVal > 100) progressVal = 100;
                float percentage = ((float)progressVal / 100.0f);

                Brush backColorBrush = new SolidBrush(cellStyle.BackColor);
                Brush foreColorBrush = new SolidBrush(cellStyle.ForeColor);
                Brush barColorBrush = new SolidBrush(GetColorBetween(cellStyle.BackColor,
                    cellStyle.ForeColor, progressVal == 100 ? 0.2f : 0.3f));

                base.Paint(g, clipBounds, cellBounds,
                    rowIndex, cellState, value, formattedValue, errorText,
                    cellStyle, advancedBorderStyle, (paintParts & ~DataGridViewPaintParts.ContentForeground));

                var s = progressVal.ToString() + "%";
                var sz = g.MeasureString(s, cellStyle.Font);
                int dy = (cellBounds.Height - this.DataGridView.RowTemplate.Height) / 2;

                g.FillRectangle(barColorBrush, cellBounds.X + 2, cellBounds.Y + 2, Convert.ToInt32((percentage * cellBounds.Width - 4)), cellBounds.Height - 4);
                g.DrawString(s, cellStyle.Font, foreColorBrush, cellBounds.X + (cellBounds.Width / 2) - sz.Width / 2 - 5, cellBounds.Y + 2 + dy);
            }
            catch (Exception e) { }
        }
开发者ID:Camel-RD,项目名称:MyDownloder,代码行数:27,代码来源:DataGridViewProgressColumn.cs

示例12: Paint

 protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
     if(this.fNowCalculating) {
         this.PaintBackGround(graphics, advancedBorderStyle, cellStyle, cellBounds);
         paintParts &= ~(DataGridViewPaintParts.ContentBackground | DataGridViewPaintParts.Background);
     }
     base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
 }
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:7,代码来源:DataGridViewProgressBarCell.cs

示例13: Paint

			protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex,
				DataGridViewElementStates dataGridViewElementState, object value, object formattedValue, string errorText,
				DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle,
				DataGridViewPaintParts paintParts) {
				graphics.FillRectangle(new SolidBrush(SystemColors.Control), cellBounds);
				if (DataGridView.SelectedCells.Count > 0 &&
				    (DataGridView.SelectedCells[0].ColumnIndex == ColumnIndex ||
				     DataGridView.SelectedCells[0].RowIndex == RowIndex)) {
					ControlPaint.DrawBorder(graphics, cellBounds,
						SystemColors.ControlDarkDark, 1, ButtonBorderStyle.Solid,
						SystemColors.ControlDarkDark, 1, ButtonBorderStyle.Solid,
						SystemColors.ButtonFace, 1, ButtonBorderStyle.Solid,
						SystemColors.ButtonFace, 1, ButtonBorderStyle.Solid);
				}
				else {
					ControlPaint.DrawBorder(graphics, cellBounds,
						SystemColors.ButtonHighlight, 1, ButtonBorderStyle.Solid,
						SystemColors.ButtonHighlight, 1, ButtonBorderStyle.Solid,
						SystemColors.ControlDarkDark, 1, ButtonBorderStyle.Solid,
						SystemColors.ControlDarkDark, 1, ButtonBorderStyle.Solid);

					graphics.DrawLine(SystemPens.ButtonFace,
						cellBounds.Left, cellBounds.Bottom,
						cellBounds.Left, cellBounds.Bottom);
				}

				var bounds = cellBounds;
				bounds.Inflate(-2, -2);
				TextRenderer.DrawText(graphics, (string)formattedValue, cellStyle.Font, bounds,
					cellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Left);
			}
开发者ID:mamingxiu,项目名称:dnExplorer,代码行数:31,代码来源:GridView.cs

示例14: Paint

        //绘制列头checkbox
        protected override void Paint(System.Drawing.Graphics graphics,
                                      System.Drawing.Rectangle clipBounds,
                                      System.Drawing.Rectangle cellBounds,
                                      int rowIndex,
                                      DataGridViewElementStates dataGridViewElementState,
                                      object value,
                                      object formattedValue,
                                      string errorText,
                                      DataGridViewCellStyle cellStyle,
                                      DataGridViewAdvancedBorderStyle advancedBorderStyle,
                                      DataGridViewPaintParts paintParts)
        {
            base.Paint(graphics, clipBounds, cellBounds, rowIndex,
                        dataGridViewElementState, value,
                        formattedValue, errorText, cellStyle,
                        advancedBorderStyle, paintParts);

            Point p = new Point();
            Size s = CheckBoxRenderer.GetGlyphSize(graphics,
            System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal);
            p.X = cellBounds.Location.X + (cellBounds.Width / 2) - (s.Width / 2) - 1;//列头checkbox的X坐标
            p.Y = cellBounds.Location.Y + (cellBounds.Height / 2) - (s.Height / 2);//列头checkbox的Y坐标
            _cellLocation = cellBounds.Location;
            checkBoxLocation = p;
            checkBoxSize = s;
            if (_checked)
                _cbState = CheckBoxState.CheckedNormal;
            else
                _cbState = CheckBoxState.UncheckedNormal;
            CheckBoxRenderer.DrawCheckBox(graphics, checkBoxLocation, _cbState);
        }
开发者ID:linyc,项目名称:CTool,代码行数:32,代码来源:DataGridViewCheckBoxHeaderCell.cs

示例15: Paint

        protected override void Paint(Graphics graphics,
            Rectangle clipBounds, Rectangle cellBounds, int rowIndex,
            DataGridViewElementStates dataGridViewElementState,
            object value, object formattedValue, string errorText,
            DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle,
            DataGridViewPaintParts paintParts)
        {
            base.Paint(graphics, clipBounds, cellBounds, rowIndex, dataGridViewElementState, value,
                formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
            graphics.FillRectangle(new SolidBrush(cellStyle.BackColor), cellBounds);

            CheckBoxRegion = new Rectangle(
                cellBounds.Location.X + 1,
                cellBounds.Location.Y + 2,
                25, cellBounds.Size.Height - 4);


            if (this.checkAll)
                ControlPaint.DrawCheckBox(graphics, CheckBoxRegion, ButtonState.Checked);
            else
                ControlPaint.DrawCheckBox(graphics, CheckBoxRegion, ButtonState.Normal);

            Rectangle normalRegion =
                new Rectangle(
                cellBounds.Location.X + 1 + 25,
                cellBounds.Location.Y,
                cellBounds.Size.Width - 26,
                cellBounds.Size.Height);

            graphics.DrawString(value.ToString(), cellStyle.Font, new SolidBrush(cellStyle.ForeColor), normalRegion);

        }
开发者ID:cuongpv88,项目名称:work,代码行数:32,代码来源:DGVColumnHeader.cs


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