Exemple #1
0
 private void metroGrid1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
 {
     if (e.RowIndex == metroGrid1.NewRowIndex)
     {
         e.PaintHeader(DataGridViewPaintParts.Background | DataGridViewPaintParts.Border);
         e.PaintCells(e.ClipBounds, DataGridViewPaintParts.All);
         e.Handled = true;
     }
 }
Exemple #2
0
 private void BatchHash_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
 {
     e.PaintCells(e.ClipBounds, DataGridViewPaintParts.All);
     e.PaintHeader(DataGridViewPaintParts.Background
                   | DataGridViewPaintParts.Border
                   | DataGridViewPaintParts.Focus
                   | DataGridViewPaintParts.SelectionBackground
                   | DataGridViewPaintParts.ContentForeground);
     e.Handled = true;
 }
 public void PaintCells_InvalidRowIndex_ThrowsInvalidOperationException(int rowIndex)
 {
     using (var image = new Bitmap(10, 10))
         using (Graphics graphics = Graphics.FromImage(image))
         {
             var dataGridView = new DataGridView();
             dataGridView.Columns.Add("name", "text");
             var e = new DataGridViewRowPrePaintEventArgs(dataGridView, graphics, Rectangle.Empty, Rectangle.Empty, rowIndex, DataGridViewElementStates.Displayed, null, new DataGridViewCellStyle(), false, false);
             Assert.Throws <InvalidOperationException>(() => e.PaintCells(new Rectangle(1, 2, 3, 4), DataGridViewPaintParts.None));
         }
 }
 public void PaintCells_ValidRowIndex_Success()
 {
     using (var image = new Bitmap(10, 10))
         using (Graphics graphics = Graphics.FromImage(image))
         {
             var dataGridView = new DataGridView();
             dataGridView.Columns.Add("name", "text");
             var e = new DataGridViewRowPrePaintEventArgs(dataGridView, graphics, Rectangle.Empty, Rectangle.Empty, 0, DataGridViewElementStates.Displayed, null, new DataGridViewCellStyle(), false, false);
             e.PaintCells(new Rectangle(1, 2, 3, 4), DataGridViewPaintParts.None);
         }
 }
Exemple #5
0
 private void dataGridViewInputs_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
 {
     if (e.RowIndex == _Index)
     {
         using (var brush = new SolidBrush(_CurrentFrameBackgroundColor))
         {
             e.Graphics.FillRectangle(brush, e.RowBounds);
             e.PaintCells(e.ClipBounds, DataGridViewPaintParts.All & ~DataGridViewPaintParts.Background);
             e.Handled = true;
         }
     }
 }
        private void SandpilePalette_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
        {
            e.PaintCells(e.ClipBounds, DataGridViewPaintParts.All);
            e.PaintHeader(DataGridViewPaintParts.Background
                          | DataGridViewPaintParts.Border
                          | DataGridViewPaintParts.Focus
                          | DataGridViewPaintParts.SelectionBackground);
            e.Handled = true;

            e.Graphics.DrawString(e.RowIndex.ToString(),
                                  e.InheritedRowStyle.Font,
                                  Brushes.Black,
                                  new PointF(e.RowBounds.X + 2, e.RowBounds.Y + 2));
        }
Exemple #7
0
        void dataGridView_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
        {
            // Help removing indicator/pointer in row header of datagridview
            // https://social.msdn.microsoft.com/Forums/windows/en-US/346e5839-1813-472b-8b3a-7344118819b3/help-removing-indicatorpointer-in-row-header-of-datagridview?forum=winformsdatacontrols

            e.PaintCells(e.ClipBounds, DataGridViewPaintParts.All);
            e.PaintHeader(
                DataGridViewPaintParts.Background |
                DataGridViewPaintParts.Border |
                DataGridViewPaintParts.Focus |
                DataGridViewPaintParts.SelectionBackground |
                DataGridViewPaintParts.ContentForeground);

            e.Handled = true;
        }
 protected override void OnRowPrePaint(DataGridViewRowPrePaintEventArgs e)
 {
     e.PaintCells(e.RowBounds, e.PaintParts);
     e.PaintHeader(true);
     e.Handled = true;
 }
Exemple #9
0
        void GridOpCode_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            DataGridViewRow r = GridOpCode.Rows[e.RowIndex];

            if (r == null || r.IsNewRow || r.DataBoundItem == null)
            {
                return;
            }

            if (!(r.DataBoundItem is Instruction i))
            {
                return;
            }

            e.PaintCells(e.RowBounds, DataGridViewPaintParts.All);
            e.Handled = true;

            if (i.Color != Color.Empty)
            {
                using (Brush br = new SolidBrush(i.Color))
                {
                    e.Graphics.FillRectangle(br, e.RowBounds);
                }
            }

            if (Debugger != null && Debugger.CurrentInstructionIndex == i.Location.Index)
            {
                bool error = Debugger.IsError;

                using (Brush br = new SolidBrush(Color.FromArgb(30, error ? Color.DarkRed : Color.Lime)))
                {
                    e.Graphics.FillRectangle(br, e.RowBounds);
                    e.Graphics.DrawRectangle(error ? Pens.Red : Pens.Green,
                                             e.RowBounds.X, e.RowBounds.Y, e.RowBounds.Width - 1, e.RowBounds.Height - 1);
                }
            }

            if (i.BreakPoint)
            {
                using (Brush br = new SolidBrush(Color.FromArgb(50, Color.Red)))
                {
                    e.Graphics.FillRectangle(br, e.RowBounds);
                }
            }

            switch (i.BorderStyle)
            {
            case RowBorderStyle.All:
            {
                e.Graphics.DrawRectangle(Pens.DimGray, e.RowBounds.X, e.RowBounds.Y, e.RowBounds.Width - 1, e.RowBounds.Height - 1);
                break;
            }

            case RowBorderStyle.OnlyLeftAndRight:
            {
                e.Graphics.DrawLine(Pens.DimGray, e.RowBounds.X, e.RowBounds.Y, e.RowBounds.X, e.RowBounds.Bottom);
                e.Graphics.DrawLine(Pens.DimGray, e.RowBounds.Right - 1, e.RowBounds.Y, e.RowBounds.Right - 1, e.RowBounds.Bottom);
                break;
            }

            case RowBorderStyle.EmptyBottom:
            {
                e.Graphics.DrawLine(Pens.DimGray, e.RowBounds.X, e.RowBounds.Y, e.RowBounds.Right - 1, e.RowBounds.Y);
                goto case RowBorderStyle.OnlyLeftAndRight;
            }

            case RowBorderStyle.EmptyTop:
            {
                e.Graphics.DrawLine(Pens.DimGray, e.RowBounds.X, e.RowBounds.Bottom, e.RowBounds.Right - 1, e.RowBounds.Bottom);
                goto case RowBorderStyle.OnlyLeftAndRight;
            }
            }
        }