/// <summary> /// 实现在列表没有记录的时候,可以录入一个不存在的记录,类似ComoboEidt功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void CustomGridLookUpEdit_ProcessNewValue(object sender, DevExpress.XtraEditors.Controls.ProcessNewValueEventArgs e) { if (!DisableAddNew && !this.DesignMode) { string displayName = this.Properties.DisplayMember; string valueName = this.Properties.ValueMember; string display = e.DisplayValue.ToString(); DataTable dtTemp = this.Properties.DataSource as DataTable; if (dtTemp != null) { DataRow[] selectedRows = dtTemp.Select(string.Format("{0}='{1}'", displayName, display.Replace("'", "‘"))); if (selectedRows == null || selectedRows.Length == 0) { DataRow row = dtTemp.NewRow(); row[displayName] = display; row[valueName] = display; dtTemp.Rows.Add(row); dtTemp.AcceptChanges(); } } e.Handled = true; } }
private void treeListLookUpEdit1_ProcessNewValue(object sender, DevExpress.XtraEditors.Controls.ProcessNewValueEventArgs e) { TreeList TreeList = treeListLookUpEdit1.Properties.TreeList; if (virtualMode) { e.Handled = true; ID++; TreeList.AppendNode(new object[] { e.DisplayValue, "Little-Medium", ID }, null); } }