1. Add two tables to the database with the primary foreign key relationship
Primary key table:
FOREIGN key table:
2. Drag the Gridcont control to the toolbar and add the corresponding column, where the "province" is modified, the value of "FileName" corresponds to the database column name, the following "(Name)" can be the same as FileName;
Filename:provinceid
(Name):P Rovinceid
3. Locate the "Columnedit" attribute and click Add "Searchlookupedit" control;
4. Click the "Repository" button on the left side of the window and click "In-place Editor Repository" to modify the properties.
Valuemenber:id (primary key table ID)
Displaymember:name (primary key table Name, used to display data in the table)
Other properties (not set):
Popupformsize: Size of the container
Nulltext: The value displayed when empty
Optionsview->newitemrowposition:button (do not know what the use, online said it is best to set up in this way, the bottom layer will be more than a blank line)
5. Click the colon to modify the columns that need to be displayed
Filename:name (in the primary key table)
Width: Wide
6. Add a data source (note: Gridcontrol also needs to load the data, otherwise repositoryitemsearchlookupedit cannot display the data)
Staffgrid.datasource == _db. Provinces.orderby (p = p.name). ToList ();
7.
WinForm------A method that uses Searchlookupedit controls in a Gridcontrol control