if(gridView1.Columns["CHKFLAG"] != null) { gridColumn= gridView1.Columns["CHKFLAG"]; varcheckEdit=new RepositoryItemCheckEdit(); gridControl1.RepositoryItems.Clear(); gridControl1.RepositoryItems.Add(checkEdit); gridColumn.ColumnEdit= checkEdit; checkEdit.QueryCheckStateByValue +=checkEdit_QueryCheckStateByValue; gridColumn.Width= 20; gridColumn.OptionsColumn.ShowCaption= false; gridColumn.OptionsColumn.AllowEdit =true; }
/// <summary> /// 实现gridview列复选框可选 /// </summary> /// <paramname="sender"></param> /// <paramname="e"></param> private voidcheckEdit_QueryCheckStateByValue(object sender,DevExpress.XtraEditors.Controls.QueryCheckStateByValueEventArgs e) { varval = e.Value != null ? e.Value.ToString() : "True"; switch(val) { case"True": e.CheckState= CheckState.Checked; break; case"False": e.CheckState= CheckState.Unchecked; break; case"Yes": gotocase "True"; case"No": gotocase "False"; case"1": gotocase "True"; case"0": gotocase "False"; default: e.CheckState= CheckState.Checked; break; } e.Handled= true; } |