private DataGridViewCell currCell = null;

                  //-----------------------------------------------------------------------
                  /// <summary>
                  
          /// CurrentCellChanged時(shí)発生します
                  
          /// </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時(shí)発生します
                  
          /// 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 閱讀(260) 評(píng)論(0)  編輯  收藏 所屬分類: .Net
          主站蜘蛛池模板: 武陟县| 慈利县| 麻栗坡县| 交口县| 沙河市| 峨边| 阳朔县| 三河市| 白玉县| 临潭县| 庆云县| 东兰县| 吉木乃县| 图木舒克市| 潜江市| 武隆县| 易门县| 靖远县| 英吉沙县| 昌黎县| 礼泉县| 宜城市| 盘锦市| 商南县| 从化市| 富阳市| 时尚| 上林县| 河曲县| 卫辉市| 车险| 黄山市| 佛坪县| 西城区| 徐汇区| 襄城县| 都江堰市| 济宁市| 荣昌县| 乐山市| 宜城市|