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 DataGridViewRowPostPaintEventArgs(dataGridView, graphics, Rectangle.Empty, Rectangle.Empty, 0, DataGridViewElementStates.Displayed, null, new DataGridViewCellStyle(), false, false);
             e.PaintCells(new Rectangle(1, 2, 3, 4), DataGridViewPaintParts.None);
         }
 }
 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 DataGridViewRowPostPaintEventArgs(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));
         }
 }
Esempio n. 3
0
        //sor keret szin
        private void DataGridViewRendelesek_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            if (dgvRendelesek.SelectedCells.Count > 0)
            {
                if (e.RowIndex == dgvRendelesek.SelectedCells[0].RowIndex)
                {
                    e.PaintCells(e.RowBounds, DataGridViewPaintParts.Border);
                    using (Pen p = new Pen(Color.Blue, 3))
                    {
                        Rectangle rect = e.RowBounds;

                        rect.Height -= 2;

                        e.Graphics.DrawRectangle(p, rect);
                    }
                }
            }
        }