Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for Windows Forms / Adding a multi-column combobox to UltraGrid that can select multiple items

Adding a multi-column combobox to UltraGrid that can select multiple items

New Discussion
Mark Roberts
Mark Roberts asked on Jan 4, 2021 7:17 PM

We currently have an UltraGrid that has a column that uses an UltraDropDown control.  The user clicks the dropdown and see a multi-column grid of data that they can select 1 row from.  After selection, a value is placed in that grid cell.  We would now like the users to be able to select multiple rows (by clicking in a checkbox).  The UltraDropDown can only select 1 row.  I can get an UltraComboEditor control to show the checkbox, but it seems only to be able to display 1 column of data (because of the ValueList?).  I have seen several examples (very old ones) of an UltraCombo control being used, but I can’t get any of them to work.  Is there a current example of something like this – with an UltraGrid using a multi-column control that can select multiple items?  I am using version 20 of Ultimate UI for Windows Forms.  Thanks!

Mark Roberts

PDS, Inc.

Sign In to post a reply

Replies

  • 0
    Ivan Kitanov
    Ivan Kitanov answered on Dec 15, 2020 12:01 PM

    Hello Mark,

    I believe that this article is relevant to what you are looking for. It demonstrates how multiple values can be selected from a WinCombo.

    Following it I have created a small sample application which places an UltraCombo into one of the grids columns by using the columns EditorComponent property.  Please test it on your side and let me know how it behaves. If this is not an accurate demonstration of what you are trying to achieve please feel free to modify it and send it back to me along with steps to reproduce. Alternatively please feel free to provide your own sample. Remove any external dependencies and code that is not directly related to the issue, zip your application and attach it.

    Having a working sample on my side, which I can debug, is going to be very helpful in finding the root cause of this behavior.

    Please let me know if you need further assistance.

    Regards,Ivan Kitanov

    • 0
      Mark Roberts
      Mark Roberts answered on Dec 16, 2020 10:06 PM

      Ivan,

      Thanks for your example code, it was very helpful and got me most of the way to getting things working.

      There were a couple of differences that I wanted to record here in case others run into the same situations.

      1. Your example had the code in the Form_Load event, but I needed it to be elsewhere because my grid is populated based on another selection on the page, so I had to put my code into the grid_InitializeLayout method.  The problem with that is that event is called multiple times so I was getting an error trying to add the checkbox column again and again with the same column name.

      2. One difference in my situation is that I want the checkbox column only used in a template row (for adding a new row to the grid).  Since that is only done once, I was able to overcome issue #1 by moving the sample code to the grid_InitializeTemplateAddRow() method.

      Thanks again for your help!  I will mark your response as the answer.

      Mark

    • 0
      Mark Roberts
      Mark Roberts answered on Dec 17, 2020 4:49 AM

      Ivan,

      I do have one more issue with the UltraCombo within the UltraGrid – see the screen shots in the attached document.  After I click the dropdown to bring up the grid of states, it looks fine, but on the FIRST click on a checkbox (AK in the first screen shot) it quickly checks the checkbox, puts the “AK” in the editor, unchecks the checkbox, and then seems to resize the columns.  After the first click (see second screen shot), it works exactly as I would expect – in this case I select Alabama & Arkansas and both are checked and both values are in the editor.  Is there some event that would be firing for only the first click or some property that I should be setting?

      Mark

       

      • 0
        Ivan Kitanov
        Ivan Kitanov answered on Dec 17, 2020 2:36 PM

        Hello Mark,

        I’m not sure why this behavior occurs, does it put “AK” always in the editor or the value is different each time?

        In order to ensure that your issue is addressed correctly, could you recreate this behavior by modifying the sample that I have attached in my previous response or provide your own sample with code only connected to the issue and attach it to your next response?

        Looking forward to hearing from you.

        Regards,
        Ivan Kitanov

      • 0
        Mike Saltzman
        Mike Saltzman answered on Dec 17, 2020 3:01 PM

        Are you assigning the UltraCombo to the cell or the column? Since you only want it in the TemplateAddRow, it would make sense to add it to the cell. 

        So I wonder if this is some kind of timing issue or if something in the InitializeRow event is clearing the cell or re-setting the value of that cell. 

        InitializeRow fires every time you make a change to a cell, so it might be that when you check the checkbox in the UltraCombo, InitializeRow fires and something in your code there is causing it to lose the value. If that's the case, you can check e.ReInitialize inside InitializeRow to determine whether or not the row is being initialized for the first time. 

      • 0
        Mark Roberts
        Mark Roberts answered on Dec 20, 2020 8:54 AM

        Ivan & Mike,

        I have finally found the solution!!  In my last comment I attached a document with my code which was in the InitializeTemplateAddRow event.  The problem is that the first time I select a row in the UltraCombo grid, it fires the InitializeTemplateAddRow event again – so it reloads & resizes the UltraCombo grid – and that was what I was seeing that cleared out my first selection.  I have moved my code into the UltraGrid’s InitializeLayout, but I had to add a check to see if the CheckBox column was already there.  If I don’t, it tries to add it again whenever the InitializeLayout event fires again and gets an error that the Key already exists.  Hopefully, all that makes sense.  I have included the attachment again with new & old code if you care to look at it.  Thanks for all your help with my issues!!

        Mark

         

      • 0
        Ivan Kitanov
        Ivan Kitanov answered on Dec 21, 2020 9:14 AM

        Hello Mark,

        I am glad that you managed to resolve your issue.

        Thank you for choosing Infragistics!

        Regards,
        Ivan Kitanov

      • 0
        Mike Saltzman
        Mike Saltzman answered on Jan 4, 2021 3:21 PM

        That makes sense. You have to be careful with InitializeRow (or in this case InitializeTemplateAddRow) because it might not seem intuitive that these events can fire more than once for the same row. In retrospect,  "Initialize" was probably not the best name to use here. 🙂

        InitializeRow has a property on the event args called ReInitialize which tells you if the row is being initialized after the first time, but there does not appear to be a similar property for InitializeTemplateAddRow.

        It seems like you already have a solution, but if, for whatever reason, you find that your solution is not working or you run into other issues, you might consider using the InitializeRow event, instead, and just checking e.Row.IstempalteAddRow or e.Row.IsUnmodifiedTemplateAddRow to determine if the row is a TemplateAddRow or not – and then you would have access to the e.ReInitialize and that might simplify things. 

        Of course, another thing you might be able to do is to keep using InitializeTempalteAddRow and just check to see if the EditorComponent or ValueList property is already set before you re-set it. 

        Also… I'm curious about what happens when the TemplateAddRow becomes a real row. Once that row is committed, do you need to clear the dropdown? Presumably not, since you are probably just marking that cell as not editable. But it's just something you might need to think about. 

      • 0
        Mark Roberts
        Mark Roberts answered on Jan 4, 2021 7:17 PM

        Thanks for following up Mike!  The current solution seems to be working well, but it's good to know some alternative possibilities if needed.

        Mark

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Mark Roberts
Favorites
0
Replies
9
Created On
Jan 04, 2021
Last Post
5 years, 9 months ago

Suggested Discussions

Tags

Created by

Created on

Jan 4, 2021 7:17 PM

Last activity on

Feb 20, 2026 12:02 PM