Basic data:
public class Product { public int Id { get; set; } public string Model { get; set; } public string Name { get; set; } } public class Entility { private static string GetChar(int number) { string[] array = new string[] { "A","B","C","D","E","F","G","H","I"}; string result = array[number % 9]; return result; } private static string GetName(int number) { string[] array = { "Unitch data collector","MS Scanner","105SL","TSC","PH880","MS320 portable printer","PA700","DSX800 computer","HP printer" }; string result = array[number % 9]; return result; } public static List<Product> GetProductList() { List<Product> list = new List<Product>(); for (int i = 0; i < 200; i++) { Product product = new Product() { Id=100+i,Model=GetChar(i)+i.ToString()+"DLJ",Name=GetName(i)+i.ToString() }; list.Add(product); } return list; }
1. Use of SearchLookUpEdit control: Feel whether this control is tall or not.
Data binding and add row number index in front
private void Form3_Load(object sender, EventArgs e) { List<Product> list = Entility.GetProductList(); searchLookUpEdit1.Properties.DataSource = list; searchLookUpEdit1.Properties.DisplayMember = "code"; searchLookUpEdit1.Properties.ValueMember = "code"; SearchLookUpEdit1.Properties.NullText = @"Please select"; } private void searchLookUpEdit1View_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e) { if (e.RowHandle >= 0 && e.Info.IsRowIndicator) { e.Info.DisplayText = (e.RowHandle + 1).ToString(); } }
Add data column:
Simple attributes:
//Double click to display the drop-down list searchLookUpEdit1.Properties.ShowDropDown = ShowDropDown.DoubleClick; searchLookUpEdit1.Properties.ImmediatePopup = true;//Show drop-down list searchLookUpEdit1.Properties.TextEditStyle = TextEditStyles.DisableTextEditor;//This control does not allow input searchLookUpEdit1.Properties.NullText = "";//Clear the default value
2. GridLookUpEdit control is simple to use Effect:
Data binding:
List<Product> list = Entility.GetProductList();
gridLookUpEdit1.Properties.DataSource = list;
Add the displayed data column: and perform data binding to set the width of the column
GridLoolUpEdit defaults to fuzzy filtering based on the fields bound to DisplayMember.
Set the filter function based on multiple columns:
private void FilterLookup(object sender) { GridLookUpEdit edit = sender as GridLookUpEdit; GridView gridView = edit.Properties.View as GridView; FieldInfo fi = gridView.GetType().GetField("extraFilter", BindingFlags.NonPublic | BindingFlags.Instance); BinaryOperator op1 = new BinaryOperator("Id", "%" + edit.AutoSearchText + "%", BinaryOperatorType.Like); BinaryOperator op2 = new BinaryOperator("Model", "%" + edit.AutoSearchText + "%", BinaryOperatorType.Like); BinaryOperator op3 = new BinaryOperator("Name", "%" + edit.AutoSearchText + "%", BinaryOperatorType.Like); string filterCondition = new GroupOperator(GroupOperatorType.Or, new CriteriaOperator[] { op1, op2,op3 }).ToString(); fi.SetValue(gridView, filterCondition); MethodInfo mi = gridView.GetType().GetMethod("ApplyColumnsFilterEx", BindingFlags.NonPublic | BindingFlags.Instance); mi.Invoke(gridView, null); } private void gridLookUpEdit1_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e) { BeginInvoke(new MethodInvoker(delegate() { FilterLookup(sender); })); }
Show row number for filtered column
private void gridLookUpEdit1View_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e) { if (e.Info.IsRowIndicator && e.RowHandle >= 0) { e.Info.DisplayText = (e.RowHandle + 1).ToString(); } }
Some simple property settings:
//Double click to display the drop-down list gridLookUpEdit1.Properties.ShowDropDown = ShowDropDown.DoubleClick; gridLookUpEdit1.Properties.ImmediatePopup = true;//Show drop-down list gridLookUpEdit1.Properties.TextEditStyle = TextEditStyles.Standard;//Allow input gridLookUpEdit1.Properties.NullText = "";//Clear the default value
Set the width of the drop-down list
First on the renderings Renderings Operation process: Click on any cell in the column in the red frame, and a data selection list as shown in the green frame will pop up (this list is as long a...
Gridlookupedit can fuzzy query the value of DisplayMember by default. If you want to fuzzy query all columns, you need to add a method, which is SetGridLookupEditMoreColumnFilter, which is called. Rea...
Added a SearchLookUpEdit control to the GridControl table, but the width of the table displayed when the data is loaded is not neat and tidy. If you want to set the adaptive width, you will automatica...
The ultimate show: Column before binding you want to set is editable, setting specifies how the column can be edited Dev-GridControl (b) stated 1 First Data Binding GridControl 2 Second, find the colu...
Effect picture (multiple selection, pop-up form to add controls) SearchLookUpEdit (multiple choice) Control properties and event usage 1. Set multi-select properties 2. Pop-up form event 3. Button eve...
Effect picture SearchLookUpEdit (one single choice) 1. Control operation process 1.1 Select control (omitted) 1.2 The displayed value and return value are fields in the data table, and the contents in...
Requirements: When you drop down the content of the table, a text box needs to search for the content of multiple columns, not to mention the search speed here, but it can also meet the general needs...
Use dev's GridLookUpEdit to implement the drop-down filter completion function. Data source binding and common settings: Under normal circumstances, it will filter based on DisplayMember by default. H...
How to: Create and customize a custom GridLookUpEdit control Nov 13, 2018 4 minutes to read Assume that a GridLookUpEdit control needs to be used in multiple places, and all editors must dis...