Xceed Grid for WinForms v4.3 Documentation
Welcome to Xceed Grid for WinForms v4.3 / Task-Based Help / Appearance / How to display a description rather than an ID

In This Topic
    How to display a description rather than an ID
    In This Topic

    In order to display a description rather than an ID, you will need to use the ComboBoxViewer and the ComboBoxEditor

    This is done by binding the ComboBoxViewer and ComboBoxEditor to the table that contains the ID's descriptions and to set its DisplayFormat and ValueMember properties.

    Demonstration

    The following example demonstrates how to display a description (rather than an ID) using the ComboBoxViewer and ComboBoxEditor.

    VB.NET Copy Code

    Dim viewer As New Xceed.Grid.Viewers.ComboBoxViewer( northwindDataSet, "Products", _
                                                         "ProductID", "%ProductName%" )

    Dim editor As New Xceed.Grid.Editors.ComboBoxEditor( northwindDataSet, "Products", _
                                                         "ProductID", "%ProductName%" ) 

    GridControl1.Columns( "ProductID" ).CellEditorManager = editor
    GridControl1.Columns( "ProductID" ).CellViewerManager = viewer

    C# Copy Code

    Xceed.Grid.Viewers.ComboBoxViewer viewer = new Xceed.Grid.Viewers.ComboBoxViewer(
                             northwindDataSet, "Products", "ProductID", "%ProductName%" );

    Xceed.Grid.Editors.ComboBoxEditor editor = new Xceed.Grid.Editors.ComboBoxEditor(
                             northwindDataSet, "Products", "ProductID", "%ProductName%" ); 

    gridControl1.Columns[ "ProductID" ].CellEditorManager = editor;
    gridControl1.Columns[ "ProductID" ].CellViewerManager = viewer;

    The above code assumes that you have a ProductID column in the grid and will result in the ProductID column displaying the description of the product that corresponds to the ID.