Programming/C#

DataGridView의 Cell입력시 KeyPress / MaxLength 사용하기

SherryBirkin 2016. 11. 30. 17:39

DataGridVeiw이벤트에 EditingControlShowing추가

e.Control.KeyPress이벤트 연결


KeyPress와 연결한 함수에서


if (((DataGridViewTextBoxEditingControl)sender).Text.Length >= 제한할 길이 수 

  && ((DataGridViewTextBoxEditingControl)sender).SelectedText.Length <= 0)

      e.Handled = true;


SelectedTextLength는 블록 지정했을때 수정이 가능하게끔 하기 위함