Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
920
TemplateAddRow Combobox data source different than combobox for existing rows
posted

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

 

Parents
  • 469350
    Suggested Answer
    Offline posted

    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.

Reply Children