Home Forums WinForms controls Xceed Grid for WinForms Regarding comboboxeditor Reply To: Regarding comboboxeditor

User (Old forums)
Member
Post count: 23064

How are the two tables linked?  Normally, in the employee table, you should have some kind of value ID (Let’s call it DepartmentNumber) that identify the department, and in the Department table, you would have two columns, one being the value ID and the other the string name.  What you would do then is to have the grid bound on that value ID of the Employee table for the Department column, and the ComboBoxEditor of that column bound to the value ID of the Department Table for the ValueMember, and to the string name for the DisplayFormat.

e.g.:

      //Bind the grid to the Employees table, which will create an DepartmentNumber column that you can rename to DepartmentName
      gridControl1.SetDataBinding( this.northwindDataSet, “Employees” );
      gridControl1.Columns[ “DepartmentNumber” ].Title = “DepartmentName”;

      //Editor bound to the Departments table on the same field name, that is DepartmentNumber
      ComboBoxEditor comboEditor = new ComboBoxEditor( this.northwindDataSet, “Departments”, “DepartmentNumber”, “%DepartmentName%” );
      gridControl1.Columns[ “DepartmentNumber” ].CellEditorManager = comboEditor;

      //Idem for the Viewer
      ComboBoxViewer comboViewer = new ComboBoxViewer( this.northwindDataSet, “Departments”, “DepartmentNumber”, “%DepartmentName%” );
      gridControl1.Columns[ “DepartmentNumber” ].CellViewerManager = comboViewer;

 

Imported from legacy forums. Posted by André (had 2413 views)