IT 끄적이기/업무(SeAH - MES)

#14, 이벤트 4가지(C#, DataGrid of DevExpress, SiSFramework)

김팡 2020. 5. 25. 22:35

1. CellValueChanged 이벤트

: DataGridView 컨트롤에는 DataGridView 셀의 상태 변경을 검색 하는 데 사용할 수 있는 여러 이벤트가 있습니다. 가장 일반적으로 사용 되는 두 가지는 1) CellValueChanged 및 2) CellStateChanged 이벤트

DataGridView 셀 값의 변경 

CellValueChanged 이벤트에 대 한 처리

private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)

{

string msg = String.Format( "Cell at row {0}, column {1} value changed", e.RowIndex, e.ColumnIndex); MessageBox.Show(msg, "Cell Value Changed");

}

DataGridView 셀 상태의 변경

CellStateChanged 이벤트에 대 한 처리

private void dataGridView1_CellStateChanged(object sender, DataGridViewCellStateChangedEventArgs e)

{

DataGridViewElementStates state = e.StateChanged; string msg = String.Format("Row {0}, Column {1}, {2}", e.Cell.RowIndex, e.Cell.ColumnIndex, e.StateChanged); MessageBox.Show(msg, "Cell State Changed");

}

2. ShowingEditor 이벤트

: 특정 컬럼의 값에 따라 다른 컬럼의 입력을 허가/방지 하기 위한 이벤트 2가지 방법 존재

포커스로 마우스로 포커싱 된 row 만 변경할 수도 있고 

DataRow row = xgMasterView.GetDataRow(xgMasterView.FocusedRowHandle);  

핸들러를 통해 가져올 수도 있다

3. InitNewRow 이벤트

행추가가 일어날 때 쓰는 이벤트, NavAddButonClickEvent 와 세트다.

 

4. ValidatingEditor 이벤트

: 유효성을 체크하는 것으로 2가지 존재

1) proc 에서 수정하는 법 - proc 파일의 DataValidate 메소드에서 수정

2)BeforeSaveValidateRow 메소드에서 

  if(Func.ExistData(row["ENAME"]) == false)

            {

                MessageBox.Show("이름을 입력하세요.", "알림", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                return false;

            }

같이 존재하는지에 대해 검사.