DataGridView设定为FullRowSelect时,给CurrentCell画个美丽的口红

DataGridView设定为FullRowSelect时,给CurrentCell画个美丽的口红
private DataGridViewCell currCell =  null;

        // -----------------------------------------------------------------------
         ///   <summary>
        
///  CurrentCellChanged時発生します
        
///   </summary>
        
///   <param name="sender"></param>
        
///   <param name="e"></param>
         // -----------------------------------------------------------------------
         private  void bDgvToti_CurrentCellChanged( object sender, EventArgs e)
        {
            DataGridView dgv = (DataGridView)sender;
             if (dgv.CurrentCell !=  null)
                currCell = dgv.CurrentCell;
        }

         // -----------------------------------------------------------------------
         ///   <summary>
        
///  CellPainting時発生します
        
///  draw a LemonChiffon colored border to CurrentCell 
        
///  so that user will understand which cell is editing
        
///   </summary>
        
///   <param name="sender"></param>
        
///   <param name="e"></param>
         // -----------------------------------------------------------------------
         private  void bDgvToti_CellPainting( object sender, DataGridViewCellPaintingEventArgs e)
        {
             if (currCell !=  null && e.RowIndex == currCell.RowIndex && e.ColumnIndex == currCell.ColumnIndex)
            {
                e.Paint(e.CellBounds, DataGridViewPaintParts.All & ~DataGridViewPaintParts.Border);
                 using (Pen p =  new Pen(Color.LemonChiffon, 3)) //哎呀,我还真的没见过黄色的口红呢。。。
                {
                    Rectangle rect = e.CellBounds;
                    rect.Width -= 2;
                    rect.Height -= 2;
                    e.Graphics.DrawRectangle(p, rect);
                }
                e.Handled =  true;
            }
        }

你可能感兴趣的:(DataGridView设定为FullRowSelect时,给CurrentCell画个美丽的口红)