Hi,
(Windows Forms application)
I was wondering if a Combobox data source for the TemplateAddRow can be different than the corresponding column’s combo box for existing rows in the grid. Ideally, I would like the combo box for each row in the grid to have a different datasource.
Here is the scenario. There are two combo boxes in the grid and other related columns. One is filled with choices of Companies and the other is filled with choices of Contacts at Companies.
I am using a TemplateAddRow positioned at the top of the grid.
Adding new Records:
My first question is, can the combo box for the Template Add Row have a data source that is different than the DataSource for the existing rows in the grid. The scenario would be for a new record, the user selects a company and the ContactID combo box in the TemplateAddRow would be populated based on the selected company.
Editing Existing Records:
The ideal would be for each existing row to only show the Contacts at the selected company in that row so the Editor Component would be different for each row if the company is different.
My initial thought is to have a text box cell in the grid for the Contact Name. When that cell gets focus, show a combo box that is filled with contacts and position that combo box over the current row / cell. If the user selects a different contact, then I would assign the text value of the combo box to the grid cell with the contact name and finally hide the combo box.
Is there a more straight forward way to do this with a combo box bound to the cell in the grid?
Thanks,
NormD
Hi Norm,
I'm not entirely sure I understand what you want to do here. Are you adding two different types of records to the same list?
Anyway, the answer to your question is yes. You can populate dropdown lists for different rows in the grid with different data. There are a number of ways to do this. But in your case it sounds like you are using a an UltraCombo or UltraComboEditor as your Editor for the grid column. So all you have to do is assign a different Editor, EditorComponent, or possibly ValueList to the Cell in the TemplateAddRow. You could easily do this using the InitializeTemplateAddRow event. And you will probably also need to use the InitializeRow event to clear out the property when a row goes from a TemplateAddRow to a regular row.
It's tough to give you specifics, though, without knowing how you are currently providing the dropdown list in the column.
Hello Mike,
All of the records are the same "type" in the grid. Both of the columns that I am talking about use an UltraCombo editor The first column is a list of companies. The second column is a list of contacts. My objective is to only show the contacts in the company selected in the current row. So if I have 2 rows and row 1 is the company CISCO, I am trying to limit the Contact Name combo box shown in row 1 to employees at CISCO. Then, if the company name in row 2 is Infragistics, I only want to show contacts at Infragistics. Then, if the user starts to add a 3rd row and chooses the company Microsoft, then the list of contacts in the UltraCOmbo for the TemplateAddRow would only show employees at Microsoft.
Can this be done?
Thanks - Norm
Okay, I get it. So the combo for the contacts depends on the current selection for the company in the same row. So you have one dropdown list whose contents are based on the value of another cell.
Check out this communit article I wrote which explains how to do this in detail.
Creating a dropdown list in a grid cell whose list values are dependent on another cell - Windows Forms - Infragistics Community
do you know of any way to create the same combo, with 4 different list, in a c# winforms grid. pass in 1 value, that value then would create the combo 4 times with 4 different list.
Hi Rae,
I'm not sure what you are asking. An UltraCombo can only have a single list. So you could, of course, create 4 different UltraCombo control, each with a different data source.