Home Forums WinForms controls Xceed Grid for WinForms Update items in combo box CellEditorManager based on another cell value

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #17654 |

    I’m trying to update the items in a combo box in one cell, based off the value of a combobox in another cell. In the ActivatingControl event. I’ve tried adding and removing items from the WinComboBox returned by the CellEditorEventArgs.Control but I receive an error saying that the datasource does not support insertion or deletion. I get the same thing when attempting to remove items from the CellEditorEventArgs.Cell.CellEditorManager. I’ve also tried to update the datasource directly, which doesn’t error but doesn’t update the combo box either.

     I’m setting up the combo box as follows:

    System.Collections.Generic.

    SortedList<int, String> prodList = oApplication.getProductList();

    cbprod.TemplateControl.AllowFreeText =

    false;

    cbprod.TemplateControl.DropDownSize =

    new Size(g.Columns[1].Width * 2, 150);

    cbprod.TemplateControl.DropDownControl.Columns[0].VisibleIndex = 1;

    g.Columns[1

    ].CellEditorManager = cbprod;

    g.Columns[1

    ].CellViewerManager = new Xceed.Grid.Viewers.ComboBoxViewer(prodList.ToList(), “”, “Value”, “%Value%, %Key%”);

    g.Columns[1].CellEditorManager.ActivatingControl += AppProduct_ActivatingControl;

    g.Columns[1].CellEditorManager.DeactivatingControl += AppProduct_DeactivatingControl;

     

    Since I’ve tried 4 different ways of adding and removing items as described above, I didn’t include that code here. I was hoping to get some suggestions on how to do it with the setup I posted above.

     

    Thanks,

    Leo

    Imported from legacy forums. Posted by Leo (had 1602 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Leo,

    Just to better understand the issue, are you able to send me a small self contained sample application so that I can investigate it further? My goal is to understand and see how your application will look like with the data in the GridControl and what possible real-life values will the Grid be populated with. With your sample, I will be able to provide you with an answer that is tailored to your specific means.

    Imported from legacy forums. Posted by Marc [Xceed] (had 266 views)

    User (Old forums)
    Member
    Post count: 23064

    I worked up a quick simple example. Hopefully it’ll help you understand what I’m trying to do.

    Imported from legacy forums. Posted by Leo (had 284 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Leo,

    After reviewing your sample, I noticed that the code for the ActivatingControl/DeactivatingControl was not included. Are you able to send me your updated sample? In theory and practice, you should be able to extract the source of the ComboBox from the ActivatingControl (because you have access to the actual instance) and replace the source with a modified collection.

    I do have 1 question for you. When you say that you want the value of one ComboBox to affect the ComboBox in another cell, are you talking about:

    – another cell in a different column, same row?

    – another cell in the same column, different row?

    Imported from legacy forums. Posted by Marc [Xceed] (had 249 views)

    User (Old forums)
    Member
    Post count: 23064

    Hey Marc, I did have that code in there so I think I sent the wrong zip. I’ve attached the sample again, let me know if it’s the right one.

     I am trying to update a cell in different column in the same row.

    Imported from legacy forums. Posted by Leo (had 249 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Leo,

    After looking at your sample application, I was noticing that in the ActivatingControl event, you were checking to see if the ComboBox in the last column had a SelectedItem. The only issue is that the control was always null. You are also going to need to localize your ComboBoxes and assign them different data sources. I have updated your sample application to show the changes.

    Imported from legacy forums. Posted by Marc [Xceed] (had 1326 views)

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