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;
            }
        }
posted on 2016-04-14 08:39 Ying-er 阅读(243) 评论(0)  编辑  收藏 所属分类: .Net

只有注册用户登录后才能发表评论。


网站导航: