Different data source for different Combobox rows

4 posts, 1 answers
  1. Claude
    Claude avatar
    63 posts
    Member since:
    Apr 2009

    Posted 09 Sep 2011 Link to this post

    I have a grid view in which I want to customize the combobox entries for a given row depending on user selection of another combobox entry in the row.  Different rows would have different data sources.  Is this possible, and if so, can you tell me how to do it? 

    Thanks.
  2. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 12 Sep 2011 Link to this post

    Hello Claude,

    Please handle the CellEditorInitialized event and set the data source for the RadDropDownListEditorElement, like so:
     
    void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
    {
        if (e.Row is GridViewNewRowInfo)
        {
            if (e.ColumnIndex == 0)
            {
                var editor = e.ActiveEditor as RadDropDownListEditor;
                if (editor == null)
                {
                    return;
                }
      
                var editorElement = editor.EditorElement as RadDropDownListEditorElement;
                editorElement.DataSource= someOtherDataSource;
            }
        }
    }

    Best Regards,
    Emanuel Varga
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 14 Sep 2011 Link to this post

    Emanuel, thank you for the provided solution.

    Claude, the approch that Emanuel has provided is the right way to go in this situation. Please remember to mark his post as an answer, so that others can easily find it if they have the same question like you did.

    If you need further help, do not hesitate to write again. We will do our best to help you. 

    Greetings,
    Ivan Petrov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  5. Claude
    Claude avatar
    63 posts
    Member since:
    Apr 2009

    Posted 14 Sep 2011 Link to this post

    I didn't have a chance to test his solution until now.  It worked fine.
Back to Top