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 閱讀(258) 評論(0)  編輯  收藏 所屬分類: .Net
          主站蜘蛛池模板: 嘉兴市| 东阿县| 荣昌县| 治多县| 磐安县| 田东县| 察隅县| 济阳县| 瑞昌市| 威远县| 濮阳市| 淳化县| 华宁县| 阜新市| 瑞安市| 罗甸县| 南开区| 凉山| 平陆县| 根河市| 化隆| 新郑市| 中方县| 庆云县| 辉南县| 乌海市| 合水县| 江安县| 临颍县| 临泽县| 梁河县| 宜黄县| 临夏市| 海城市| 琼海市| 台江县| 巨鹿县| 霍邱县| 丁青县| 平罗县| 卓尼县|