Welcome to the Xceed Community Sign in | Join | Help
Community Search  

Combobox confusion

Sort Posts: Previous Next
  •  07-04-2008, 12:12 PM Post no. 13436

    Combobox confusion

    I'm trying to set up a combobox column in a grid. The column is bound to a numeric column. I want it to display text at all times, however. What's happening is that the combo box will display my text correctly when dropped down, but when I leave the cell, it reverts back to displaying the number. I suspect this is because I don't know how to use the CellEditorManager vs CellViewerManager. I tried playing with different settings, but just got more lost.

    One other annoyance is that when the combo box is dropped down and displaying my text values, it also displays the bound number unexpectedly off to the right. I don't want this. I want to see text only. I thought this was controlled by the DisplayFormat property, which I've set to %Name%. Still it displays the text and the number.

  •  07-07-2008, 4:22 PM Post no. 13454 in reply to 13436

    Re: Combobox confusion

    If the column is a string, you only need to set the CellEditorManager, but when it is a numeric one, you need to also set the CellViewerManager.

    e.g.:

    WinComboBox box = new WinComboBox(northwindDataSet, "Suppliers", "SupplierID", "%CompanyName%" );

    ComboBoxEditor cboEditor = new ComboBoxEditor( box );

    ComboBoxViewer cboViewer = new ComboBoxViewer( box );

    gridControl1.Columns[ "SupplierID" ].CellEditorManager = cboEditor;

    gridControl1.Columns[ "SupplierID" ].CellViewerManager = cboViewer;

     

    The DisplayFormat property is for the TextBox portion of the ComboBox.  To change the dropdown display, you need to set the visible property to false for each column you don't want to display.

    e.g.:

    foreach( ColumnInfo col in cboEditor.TemplateControl.Columns )

    {

        if( col.Name != "CompanyName" )

        {

            col.Visible = false;

        }

    }


    André
    Software Developer and Tech Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.