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

Wrong behavior ComboBox using SelectedIndex

7 Answers 640 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.
Bartlomiej Wojdyna
Top achievements
Rank 1
Bartlomiej Wojdyna asked on 19 Nov 2009, 10:39 AM
Hello,

I am trying set SelectedIndex = -1 to set empty item on ComboBox. It is works fine in Q2, but after upadate set DataSource cause set first item in the list. How can a set empty Item after set DataSouce?

At the moment I notice that it hapends only when SelectedIndex = -1 is set in Constructor body.
After Load it's works fine.

7 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 23 Nov 2009, 09:14 AM
Hello Bartlomiej Wojdyna,

Thank you for the question. This happens because RadComboBox binds itself after you have set the SelectedIndex to -1. I assume that you are setting SelectedIndex to -1 in your form constructor. If this is the case you need to subscribe to the Load or Shown event of your form and set SelectedIndex there. Please write again if you need further assistance.

Regards,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Bartlomiej Wojdyna
Top achievements
Rank 1
answered on 23 Nov 2009, 01:33 PM
Ok I move all my code which initialized Combo after Load Event. But I thing it should be possible to initialize Combo Item any time after set DataSource.
0
Victor
Telerik team
answered on 23 Nov 2009, 03:04 PM
Hi Bartlomiej Wojdyna,

I am afraid that it is not possible to initialize the SelectedIndex to some value before there are any items in the combo box. Since in a data binding case there are no items until there is a BindingContext, you can not set the SelectedIndex. Also please note that the CurrencyManager which is responsible for managing the current item of a data source sets the SelectedIndex of RadComboBox to 0 which happens after you set your value and therefore overwrites it. Thank you for your understanding.

Sincerely yours,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Patrick Barranis
Top achievements
Rank 1
answered on 15 Apr 2010, 06:22 PM
Hi Victor,

FWIW, I'm completely with the other poster.  I just ripped out an old control from one of your competitors and replaced it with yours in our application.  The hair-pulling I had to go through and the extra code I had to write to bypass this issue was totally unnecessary.  If you have an internal issue in the design of your control, like this one, I really believe you should do one of the following:
1) Abstract it out so your customers don't have to see it.  If someone tries to set SelectedValue or SelectedIndex, store the value internally, wait for the databind, and set it.  Do whatever is necessary so your control acts in a way that users would expect after using the System.Windows.Forms.ComboBox.
2) If you just don't have the time and resources to do the former (and can't fix the issue altogether), then at least throw an exception if a user tries to set SelectedValue or SelectedIndex before the datasource has been bound.  In other words, make it easy for the developer to figure out what they did wrong, rather than having to pull hair and then spend time Googling for this forum post (or, worse, waiting to hear back from Telerik while under a deadline).

It's issues like this that cause me to have conversations with people, at least once per month, that go like this:
Person A: Who's controls do you like best for developing your app?
Me: Well, Telerik is hands-down the best, but not for the reasons you think...
Person A: oh?
Me: I've used other controls, and while Telerik's got everyone beat on the number of features and controls, but the number of times I beat my head against the wall with silly things is frustrating.  They've got great support and helpful engineers... but sometimes I wonder if the cost/benefit ratio is as good as I think it is.  When I consider all of my time spent researching stuff I don't have to with, say, the built-in .NET controls, I'm just not sure it isn't costing me more wasted time than I think.  I recommend the Telerik controls pretty strongly, but make sure to increase your budgeted time for the "unknown trivia" you'll discover with their controls.

I really love Telerik's products, but I really feel like you need something or someone at your company to help you see how unintuitive your controls can be sometimes.  Maybe it's a person with the title "UX Director" (UX = User Experience) who focuses solely on intuitive interfaces and APIs (i.e. the developer's experience).  I really don't know, but some days, like today, I see 4 hours wasted getting something as simple as a ComboBox working, and it really makes me wonder...

Patrick (happy customer but unabashedly tough critic)
0
Victor
Telerik team
answered on 19 Apr 2010, 04:22 PM
Hello Patrick Barranis,

Thank you for the feedback. So far you are the second user to report this issue and it will be corrected for Q2 2010. We are planning on releasing a completely new list control which will address the current issues with RadListBox, namely, the data binding and overall performance, without introducing any breaking changes.
Please write again if you encounter any other functionality that you consider inconvenient or wrong. Constructive criticism is always welcome.

All the best,
Victor
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
Istvan Kurta
Top achievements
Rank 1
answered on 19 Aug 2012, 01:23 PM
Hi everybody!

Im wondering how was this bug fixed back in 2010, in Q2, because now in version 2012 Q1 a similar issue is again available for developer friendly programming. How the heck is it possible to develop something, if even a simple thing like setting the SelectedIndex is not working properly. Sometimes it sets it as it should, and in other cases it does not do anything, and i have to set the selected index two times, so that the RadDropDownList wakes up and selects the value which i want.

It is unbelievable that in one version something gets fixed, but something else is broken. And not to mention backward compatibility... That is a joke. You have to rewrite almost everything when you upgrade. We have a project, one version of it uses Telerik controls from 2009 and another version uses Telerik Controls from 2012 Q1. It is really funny to merge the two codebases, when in one version the Tab control is of type TabStrip, in another one is RadPageView, and thats only one example.

Quit the software development industry if you can't do something consistent.

Greetings,
a depressed developer, using Telerik Winforms controls.
0
Nikolay
Telerik team
answered on 22 Aug 2012, 03:26 PM
Hello,

Despite our efforts, we were not able to reproduce any issues related to the SelectedIndex of RadDropDownList. It seems that it occurs in a special case we are not aware of. Therefore, I would kindly ask you to open a new support ticket and send us a sample project which demonstrate the case. This will allow us to investigate the issue further. I want to assure you that we are covering our suite with a great number of tests to make sure that if changes should be applied, this would not break the existing functionality. 

As to the breaking changes, we are striving to keep their level at the minimum. Still, sometimes, the features that our customers require can't be implemented on top of the existing implementation, because of its current architecture. Therefore, in order to satisfy the different needs, we need to introduce a completely new component that can meet the customers' expectations and which will allow us to add even more features to it. In case a new component is introduced, the old one is kept in our codebase for an year (sometimes even more) with the Obsolete tag on top of it, as we believe that an year is enough for our customers to update their applications. In case any difficulties are met with upgrading, we are always happy to assist. In this regard, I would recommend updating regularly (at least twice an year), as this will keep your application up to date with the latest innovations and improvements of the WinForms suite.

As I mentioned at the beginning, please open a new support ticket and send us a sample project which we can investigate to solve the SelectedIndex issue. In addition, if you have any questions during updating to the latest version, we will be also glad to help.

All the best,
Nikolay
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Bartlomiej Wojdyna
Top achievements
Rank 1
Answers by
Victor
Telerik team
Bartlomiej Wojdyna
Top achievements
Rank 1
Patrick Barranis
Top achievements
Rank 1
Istvan Kurta
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or