This is a migrated thread and some comments may be shown as answers.

Multi column combo box Item selection

3 Answers 124 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Carol Watson
Top achievements
Rank 1
Carol Watson asked on 13 Feb 2010, 05:49 PM
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?

3 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 18 Feb 2010, 09:04 AM
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.
0
Carol Watson
Top achievements
Rank 1
answered on 18 Feb 2010, 07:49 PM
Hi Deyan... thanks for the assist.

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

Thanks much
0
Accepted
Deyan
Telerik team
answered on 19 Feb 2010, 08:43 AM
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.
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Carol Watson
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Carol Watson
Top achievements
Rank 1
Share this question
or