Home Forums WinForms controls Xceed Grid for WinForms Using a ComboBox as Editor in a Grid

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • Mattd [Xceed]
    Keymaster
    Post count: 8
    #16574 |

    Hi. I am evaluating your products.

    I am trying to use a Combox as Editor in the grid. I don’t understand why I can’t use a bindingList as datasource…

     Here is the code of the Form. Any cues would be great. Thanks. See code below.

     private BindingList<PartyType> _listPartyType;
            private BindingList<Personne> _listPersonne;

            public Form1()
            {
                InitializeComponent();
                _listPartyType = new BindingList<PartyType>();
               
                _listPartyType.Add(PartyType.PersonnePartyType());
                _listPartyType.Add(PartyType.CompagniePartyType());

            }

            private void winButton1_Click(object sender, EventArgs e)
            {
                _listPersonne = new BindingList<Personne>();
               
                _listPersonne.Add(Personne.Personne1());
                _listPersonne.Add(Personne.Personne2());
                _listPersonne.Add(Personne.Personne3());
               
                grid.DataSource = _listPersonne;

                ComboBoxEditor multiColumnComboBoxEditor = new ComboBoxEditor(_listPartyType, “DisplayValue”, “ID”, “%DisplayValue%”);
               
                multiColumnComboBoxEditor.TemplateControl.DropDownSize = new Size(250, 150);
                grid.Columns[“PersonnePartyType”].CellEditorManager = multiColumnComboBoxEditor;
                grid.Columns[“PersonnePartyType”].CellViewerManager = new ComboBoxViewer(_listPartyType, “DisplayValue”, “ID”, “%DisplayValue%”);

                //grid.Columns[“PersonnePartyType”].CellEditor.SetWinComboBoxStyle(multiColumnComboBoxEditor.TemplateControl);
                //dataRow.Cells[“Editors”].Value = 4;
            }

    Imported from legacy forums. Posted by Mathieu (had 891 views)

    User (Old forums)
    Member
    Post count: 23064

    This works fine.  The problem is the way you do the binding :

    new ComboBoxEditor(_listPartyType, “DisplayValue”, “ID”, “%DisplayValue%”);

    should be :

    new ComboBoxEditor(_listPartyType, string.Empty, “ID”, “%DisplayValue%”);

    The problem is that the ComboBox tries to bind to the “DisplayValue” property on the BindingList<> class, which it does not find.

     

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

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.