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 閱讀(255) 評論(0)  編輯  收藏 所屬分類: .Net
          主站蜘蛛池模板: 浦北县| 东平县| 疏勒县| 赤壁市| 马鞍山市| 开远市| 苍南县| 沐川县| 宁安市| 荣成市| 安西县| 甘孜| 九龙城区| 阜城县| 宁陕县| 万源市| 安溪县| 启东市| 方正县| 桑日县| 黄梅县| 沙河市| 湘潭县| 锡林浩特市| 云阳县| 东城区| 襄城县| 纳雍县| 新竹市| 临汾市| 蒙阴县| 蓬安县| 延安市| 山阳县| 四子王旗| 信阳市| 获嘉县| 安福县| 弋阳县| 福鼎市| 浑源县|