private void dgvUsuarios_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { if (e.RowIndex == this.usuarioBindingSource.Position) { e.DrawFocus(e.RowBounds, true); } else { using (Pen p = new Pen(System.Drawing.Color.LightGray)) { e.Graphics.DrawRectangle(p, e.RowBounds); } } }
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { if (e.RowIndex == this.messageBS.Position) { e.DrawFocus(e.RowBounds, true); } else { // Draw background Pen p; using (p = new Pen(Color.LightGray)) { e.Graphics.DrawRectangle(p, e.RowBounds); } } }
private void dgvTrainView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { int width = dgvTrainView.Columns.GetColumnsWidth(DataGridViewElementStates.Visible);// +dgvTrainView.Width - 2; Rectangle rowBounds = new Rectangle( 0, e.RowBounds.Top, width, e.RowBounds.Height - 1); if (dgvTrainView.CurrentCellAddress.Y == e.RowIndex) { //设置选中边框 e.DrawFocus(rowBounds, true); } }