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

Selected Index change firing on Text change

3 Answers 260 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Sreedath Kuttan
Top achievements
Rank 1
Sreedath Kuttan asked on 11 Jun 2008, 05:01 AM
Hi,
      I am using the RadCombobox.I want to fire an event only on Selected Index change and not on Text change.But the Selected Index change is firing on Text changed.

Is there any way to avoid this behaviour?

3 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 11 Jun 2008, 07:59 AM
Hello Sreedath ,

RadComboBox first both of this events, because when the SelectedIndex is changed, the Text of RadComboBox  is changed too. However, SelectedIndexChanged event fires before TextChanged.You can use this and do not execute TextChanged event of the SelectedIndexChanged is already fired.

See the following code for an example:
public partial class DefaultCS: XhtmlPage  
    {  
        bool isChangedFired = false;  
        private void Page_Load(object sender, System.EventArgs e)  
        {         
            Label1.Text = String.Empty;  
            if(!IsPostBack)  
            {  
                RadComboBox1.LoadContentFile("combobox.xml");  
            }  
        }  
 
        protected void RadComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)  
        {  
            if (RadComboBox1.SelectedItem != null)  
            {  
                isChangedFired = true;  
                 
            }  
            
        }  
 
        protected void RadComboBox1_TextChanged(object sender,  EventArgs e)  
        {  
            if (isChangedFired) return;  
              
        }  

Regards,
Rosi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Sreedath Kuttan
Top achievements
Rank 1
answered on 11 Jun 2008, 08:06 AM
Hi thank you for the reply.

But I don't want to fire any event on the Text change even the selected index change.Is there any way to accomplish this?


0
Rosi
Telerik team
answered on 12 Jun 2008, 11:18 AM
Hi Sreedath ,

RadComboBox does not support canceling the TextChanged event of RadComboBox .
It will always fire if the Text of  the RadComboBox is changed and you are hook on the TextChanged event.

Regards,
Rosi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox
Asked by
Sreedath Kuttan
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Sreedath Kuttan
Top achievements
Rank 1
Share this question
or