public void PaintHeader_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.PaintHeader(DataGridViewPaintParts.None));
             Assert.Throws <InvalidOperationException>(() => e.PaintHeader(true));
         }
 }
Beispiel #2
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;
     }
 }
Beispiel #3
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 PaintHeader_ValidRowIndexBool_Success(bool paintSelectionBackground)
 {
     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.PaintHeader(paintSelectionBackground);
         }
 }
        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));
        }
Beispiel #6
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;
        }
Beispiel #7
0
        private void GridRowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
        {
            var rowBounds = new Rectangle(
                RowHeadersWidth,
                e.RowBounds.Top,
                Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - HorizontalScrollingOffset + 1,
                e.RowBounds.Height);

            int realIndex = _rowManager.RealIndex(e.RowIndex);

            if (FeatureSet.FeatureSelected(realIndex))
            {
                e.PaintParts &= ~DataGridViewPaintParts.Background;
                e.PaintHeader(false);
                e.Graphics.FillRectangle(new SolidBrush(_selectionColor), rowBounds);
            }
        }
 protected override void OnRowPrePaint(DataGridViewRowPrePaintEventArgs e)
 {
     e.PaintCells(e.RowBounds, e.PaintParts);
     e.PaintHeader(true);
     e.Handled = true;
 }