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

ComboBox SelectionChangeCommitted Event

9 Answers 1558 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
Sason
Top achievements
Rank 1
Sason asked on 11 Jul 2010, 10:55 AM
Hi

are there is event like SelectionChangeCommitted in the rad ComboBox  in win forms ?
the pwoer of this event is that SelectionChangeCommitted is raised only when the user changes the combo box selection. if you use SelectedIndexChanged or SelectedValueChanged to capture user changes, because those events are also raised when the selection changes programmatically.

N
Top achievements
Rank 1
commented on 11 Mar 2022, 01:06 PM

hi,

any one sugeest suppose muticombo box suppose binded data i am trying to remove  that time conditionaly not remove

 

Dess | Tech Support Engineer, Principal
Telerik team
commented on 16 Mar 2022, 06:36 AM

Hello, Ganesh,

According to the provided information, it is difficult to me to understand what is the exact requirement that you are trying to achieve. Could you please elaborate? Once we get better understanding of the precise case, we would be able to think about an appropriate solution and provide further assistance.

9 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 14 Jul 2010, 03:57 PM
Hello Dror,

Thank you for contacting us.

Unfortunately we do not have such a property, but what you can do here is subscribe for the DropDownOpened event, and then in it subscribe for the SelectedIndexChanged event and this is how you can access "changing by user" event:
 
public Form1()
       {
           InitializeComponent();
           this.radComboBox1.DropDownOpened +=new EventHandler(radComboBox1_DropDownOpened);
       }
       bool subscribed = false;
       private void radComboBox1_DropDownOpened(object sender, EventArgs e)
       {
           if (!subscribed)
           {
               this.radComboBox1.SelectedIndexChanged += new EventHandler(radComboBox1_SelectedIndexChanged);
               subscribed = true;
           }
       }
 
       void radComboBox1_SelectedIndexChanged(object sender, EventArgs e)
       {
           this.Text = "My Text";
       }

 I hope this helps. If you have any other questions, do not hesitate to contact us.

Greetings,
Stefan
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
Jason
Top achievements
Rank 1
answered on 20 Jun 2012, 06:13 PM
In this example, wouldn't you want to unsubscribe from the event after the drop down closes, so as to not cause the SelectedIndexChanged event to fire upon a later databind?
0
Jason
Top achievements
Rank 1
answered on 20 Jun 2012, 06:17 PM
Also, is this functionality available in the newer DropDown control?
0
Jack
Telerik team
answered on 25 Jun 2012, 03:46 PM
Hi guys,

We removed RadComboBox control from our suite and now it is replaced with the RadDropDownList control. We decided that the described functionality is a very specific scenario which can be implemented with custom code and it should not be included in RadDropDownList implementation. I am posting here an updated version of the solution offered by my colleague:
bool clicked = false;
 
void list_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
    if (clicked)
    {
        Console.WriteLine("Selected by User: " + e.Position);
        clicked = false;
    }
    else
    {
        Console.WriteLine("Selected programmatically: " + e.Position);
    }
}
 
void list_PopupClosed(object sender, RadPopupClosedEventArgs args)
{
    clicked = args.CloseReason == RadPopupCloseReason.Mouse;
}

I hope it helps.
 
Kind regards,
Jack
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Francisco
Top achievements
Rank 1
answered on 05 Nov 2015, 03:17 PM

Hi Jack,

Despite this is an old subject/post, I am trying to implement your solution, but, what if I need both previous and new values?

I remember there was something like:

e.OldIndex and e.NewIndex

But now I can't find them withing PositionChangedEventArgs.

Any clue? (I would not like to use a variable to explicitly get index every time it changes)

Thanks in advanced.

Francisco

 

 

 

0
Stefan
Telerik team
answered on 06 Nov 2015, 06:01 AM
Hello Francisco,

If you do not want to use a variable, then you can use the SelectedIndexChanging event. At the time it triggers, the control will hold the old SelectedIndex, and the event will provide the new one:
void radDropDownList1_SelectedIndexChanging(object sender, Telerik.WinControls.UI.Data.PositionChangingCancelEventArgs e)
 {
     int oldIndex = radDropDownList1.SelectedIndex;
     int newIndex = e.Position;
 }

I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

Regards,
Stefan
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Francisco
Top achievements
Rank 1
answered on 11 Nov 2015, 08:40 PM

Thanks very much Stefan, it works as expected.

One more question, I am dynamically adding this RadDropDownList, and I need to pre select some default item.
I am trying with:

DataView dv = dt.DefaultView;
dv.RowFilter = "City = 'NYC'";

  

RadDropDownList ddl = new RadDropDownList();
ddl.Name = "ddl":
ddl.DataSource = dv;
ddl.DisplayMember = "Name";
ddl.ValueMember = "Id";
 
RadListDataItem li = ddl.FindItemExact(SomeId, false);
if (li != null)
{
      li.Selected = true;
}

But it seems that after line ddl.DataSource = dv items count is always 0 even when dv has items.

I am sorry for take advantage of this post.

Thanks in advance,

fco

 

0
Francisco
Top achievements
Rank 1
answered on 11 Nov 2015, 08:58 PM

Complementing previous post:

 In fact, after WinForm finish loading, The dropdown (ddl) has items, but none item is selected.

Thanks,

fco

0
Stefan
Telerik team
answered on 12 Nov 2015, 11:34 AM
Hi Francisco,

If you execute this code in the form's constructor, the item will not be selected indeed, however, if you move it to Form.Load or a later event, the item will be correctly selected.

I hope this helps.

PS. Indeed, it is better to keep just one topic per thread so the forums are easy to navigate. We will appreciate it if you separate the unrelated questions in separate threads. Thanks.

Regards,
Stefan
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Buttons, RadioButton, CheckBox, etc
Asked by
Sason
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Jason
Top achievements
Rank 1
Jack
Telerik team
Francisco
Top achievements
Rank 1
Share this question
or