grsmichael 发表于 2013-11-27 12:30:26

GridView列实现复选框可选(源码)

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;}
页: [1]
查看完整版本: GridView列实现复选框可选(源码)