I'm having a heck of a time getting this to work. I am using an UltraCombo as the EditorControl in a grid cell. I'm using this because I need to display multiple columns in the dropdown. Also, each row has to have a different DataSource for the UltraCombo.
I have assigned the DataSource for the UltraCombo (it is valid, with rows as expected), but the displayed text in the cell is just the value, not the specified display column, and when clicking the dropdown in the cell, no content is shown.
I have never used the UltraCombo in this scenario before..
Here's code I have setting the valuelist and EditorControl in the grid's InitializeRow event. I've also tried this in the AfterRowActivate event handler to the same result.
Me.cboAccount.DataSource = CurrentRowDataTable
Me.cboAccount.DisplayMember = "AccountName"
Me.cboAccount.ValueMember = "AccountID"
e.Row.Cells("AccountID").EditorControl = Me.cboAccount
Probably missing something obvious... Thanks in advance..
My best guess is that you are creating the UltraCombo control in code and you are never adding it to the Controls collection on the form. It therefore has no BindingContext, so it cannot get any data. It will also not be disposed with the form unless you add it to the Controls collection, so this is a good idea to do, anyway.
Mike,
Thanks for the response. However, I am adding it to the design surface. Any other ideas what might be going on here?
Thanks.
By the way, there's a sample of Approach 1 here:
Creating a dropdown list in a grid cell whose list values are dependent on another cell - Windows Forms - Infragistics Community
Hi,
Okay, I think maybe I have fundamentally misunderstood what you are trying to do here. Using a single UltraCombo control and populating it in InitializeLayout is not a good idea. You are making the assumption that the last row that was initialized just happens to be the one the user is dropping down and that is not the case. InitializeRow fires when the row is created and again any time anything in that row changes. So when you drop down the list with what you have here, what shows up on the list will be totally arbitrary based on the last row that just happened to be initialized.
If you want a different list in each row, then there are two basic approaches you can take.
Approach 1
Populate the UltraCombo with all possible rows and then using the filtering capabilities of the UltraCombo to filter out the ones that are not valid for that grid row.
With this approach, you would use an event that fires before the list is dropped down for a specific row to adjust the filtering. I would probably use BeforeRowActivate, but BeforeCellActivate is also a viable option.
Approach 2
Use a different instance of the UltraCombo for each row.
In this case, you would create a new UltraCombo control, populate it, and assign it to the cell in InitializeRow. For efficiency, you would probably want to create some sort of caching mechanism and re-use the same UltraCombo instance for all grid rows that need the same list.
Thanks for you help Mike, I am still unable to get this going. Unfortunately, it is not a simple matter for me to get a working sample project going..
Is the code shown above appropriate for inclusion in the InitializeRow handler? Or in the AfterRowActivate handler? Do you have any other recommendations for how this should be done or snippets?
Is there any documentation anywhere for this type of scenario?
I am going to use the grid's built in functionality and forgo the use of the UltraCombo (and thus lose some of the desired functionality) until I can get it figured out..
Okay, so does the UltraCombo show the data if you drop it down on the form outside of the grid? Your original post seems to indicate that it does. You say that there are rows, but it's not clear how you determined that, so I just want to make sure.
If you are only using the UltraCombo to provide the dropdown list for the cell, then you could assign it to the cell's ValueList property instead of EditorControl and it will have essentially the same effect. So you might want to try that just as a test.
If none of that helps, I'm afraid I am at a loss to explain this behavior. Perhaps you could post a small sample project demonstrating the issue so I can take a look?