Multi column combo box Item selection

4 posts, 1 answers
  1. Carol Watson
    Carol Watson avatar
    21 posts
    Member since:
    Jan 2010

    Posted 13 Feb 2010 Link to this post

    Hi...
    I have a multi column combo box bound to a binding adapter that is on a form.  I would like the combo to present a list of options , allowing to user to select one. 
    This trouble I am having is, when the form loads, the combo box by default selects the first item in the list.  I have the datasource, Display member and Value member properties set. 

    Is there a way to have this combo present the list (allowing me to refresh the datatable and binding adapter) with out selecting the first item in the list upon load?

  2. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 18 Feb 2010 Link to this post

    Hi Carol,

    Thank you for contacting us.

    The default behavior of the RadMultiColumnComboBox is to display the text of the DisplayMember column for the current selection in the control. When you bind the control to a data source, the selection in the grid inside the combo box is changed and the control automatically reflects this in its text box part.

    There is a way, however, to prevent this from happening. Take a look at the following code snippet:

    public Form1()
            {
                InitializeComponent();
                this.radMultiColumnComboBox1.MultiColumnComboBoxElement.EditorControl.CurrentRowChanging += new Telerik.WinControls.UI.CurrentRowChangingEventHandler(EditorControl_CurrentRowChanging);
      
            }
            bool loading;
            void EditorControl_CurrentRowChanging(object sender, Telerik.WinControls.UI.CurrentRowChangingEventArgs e)
            {
                e.Cancel = this.loading;
            }
      
            private void Form1_Load(object sender, EventArgs e)
            {
                // TODO: This line of code loads data into the 'nORTHWINDDataSet.Customers' table. You can move, or remove it, as needed.
                this.loading = true;
                this.customersTableAdapter.Fill(this.nORTHWINDDataSet.Customers);
                this.loading = false;
            }

    As you can see, I have defined a boolean variable named 'loading' which I set to true before filling the table adapter used to bind the grid, and afterwards set to false. I also use the CurrentRowChanging event of the Grid View inside the multi column combo box. In the handler of this event, I assign the value of the loading variable to the Cancel property of the Event Args object. Since the loading variable will have its value set to true only when you bind the control, it will always prevent the current row from changing and thus updating the text box part of the control in this case.

    I hope this is helpful. You can write back if you need further assistance on this case.

    All the best,
    Deyan
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Carol Watson
    Carol Watson avatar
    21 posts
    Member since:
    Jan 2010

    Posted 18 Feb 2010 Link to this post

    Hi Deyan... thanks for the assist.

    I work with VB... could you repost using VB...

    Thanks much
  5. Answer
    Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 19 Feb 2010 Link to this post

    Hello Carol,

    Thanks for writing back. Yes, I can give you the code in VB:

    Public Sub New()
        InitializeComponent()        
        AddHandler Me.radMultiColumnComboBox1.MultiColumnComboBoxElement.EditorControl.CurrentRowChanging, AddressOf EditorControl_CurrentRowChanging
    End Sub
      
    Private loading As Boolean
    Private Sub EditorControl_CurrentRowChanging(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.CurrentRowChangingEventArgs)
        e.Cancel = Me.loading
    End Sub
      
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
          
        Me.loading = True
        Me.customersTableAdapter.Fill(Me.nORTHWINDDataSet.Customers)
        Me.loading = False
    End Sub

    I would also like to ask you to update your profile that you are using VB so that we directly send you code in VB in future tickets.

    Thanks for your time and do not hesitate to write back in case of further questions.

    All the best,
    Deyan
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top