//GridView下拉选择框设置(数据字典)
public static void SetGridCombbox(DevExpress.XtraGrid.Views.Grid.GridView grvTemp, string ColumName, int DictionaryID,Boolean isTextEditable,Boolean bOnlyUserRemark=false)
{
string strSql = "";
if (bOnlyUserRemark)
strSql = "select Remark as Value from DictionaryDetail where DictionaryID = " + DictionaryID;
else
strSql = "select DetailName as Value from DictionaryDetail where DictionaryID = " + DictionaryID;
DataTable dtTemp = null;
dtTemp = new DataTable();
dtTemp = sqlHelper.ExecuteDataTable(Common.ConnString, CommandType.Text, strSql, null);
RepositoryItemComboBox ricbo; // 下拉框
ricbo = new RepositoryItemComboBox();
for (int i = 0; i < dtTemp.Rows.Count; i++)
{
ricbo.Items.Add(dtTemp.Rows[i][0].ToString());
}
if (isTextEditable == true)
{
ricbo.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;
}
else
{
ricbo.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
}
grvTemp.Columns[ColumName].ColumnEdit = ricbo;
grvTemp.Columns[ColumName].OptionsColumn.AllowMove = false;
}
备注,这个只是用于 Grid中绑定ComboBoxEdit下拉框的,如果绑定LookUpEdit 下拉框,请参照上一篇