Dev控件的用法
1、DevExpress.XtraEditors.LookUpEdit的基本用法
public void InitLookUpEditor() { // this.lookupEditFields.Properties.Columns.AddRange(new DevExpress.XtraEditors.Controls.LookUpColumnInfo[] { new DevExpress.XtraEditors.Controls.LookUpColumnInfo("DisplayMember", "DisplayMember", 20, DevExpress.Utils.FormatType.None, "", true, DevExpress.Utils.HorzAlignment.Default, DevExpress.Data.ColumnSortOrder.None), new DevExpress.XtraEditors.Controls.LookUpColumnInfo("ValueMember", "", 20, DevExpress.Utils.FormatType.None, "", false, DevExpress.Utils.HorzAlignment.Default, DevExpress.Data.ColumnSortOrder.None)}); DataTable dt = new DataTable(); dt.Columns.Add("ValueMember"); dt.Columns.Add("DisplayMember"); dt.Columns.Add("DataType"); dt.Columns.Add("IsExtandedField"); DataRow row = dt.NewRow(); row["DataType"] = ""; row["IsExtandedField"] = true; row["DisplayMember"] = ""; row["ValueMember"] = ""; dt.Rows.Add(row); this.lookupEditFields.Properties.DisplayMember = "DisplayMember"; this.lookupEditFields.Properties.ValueMember = "ValueMember"; this.lookupEditFields.Properties.DataSource = dt; if (dt.Rows.Count > 0) { //自动搜索datasouse,选择与之匹配的值,没有的情况下赋值null ,value的值必须与valuemember的数据类型一致。 lookupEditFields.EditValue = Convert.ToString(dt.Rows[0]["ValueMember"]); //this.lookupEditFields.ItemIndex = 0; } }
想取这行数据的DataType值:
string dataType = Convert.ToString(cboList.GetColumnValue("DataType"));
2、DevExpress.XtraEditors.ComboBoxEdit的基本用法
public void InitComboxEditou() { comboBoxOperator.Properties.Items.Clear(); comboBoxOperator.Properties.Items.AddRange(new object[] { "等于","大于","大于等于","小于","小于等于","不等于" }); comboBoxOperator.EditValue = "等于"; }