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
          主站蜘蛛池模板: 深水埗区| 石台县| 开原市| 绩溪县| 鄂伦春自治旗| 清涧县| 西峡县| 十堰市| 涿州市| 大兴区| 哈巴河县| 陈巴尔虎旗| 师宗县| 什邡市| 凤庆县| 博爱县| 郯城县| 进贤县| 上犹县| 巴青县| 西乌珠穆沁旗| 兰考县| 兖州市| 余江县| 利川市| 泰州市| 平泉县| 大英县| 临桂县| 内黄县| 汽车| 昆山市| 云龙县| 凉山| 高淳县| 荆门市| 贵南县| 年辖:市辖区| 台江县| 徐水县| 赤峰市|