Switching combobox between checkbox = true and checkbox=false

1 Answer 188 Views
ComboBox
Neil
Top achievements
Rank 1
Neil asked on 23 Feb 2022, 09:18 PM

Hi,

     I have a combobox. Under most circumstances I want it set to the dropdown mode (checkbox=false). In a certain cases I would like the combobox to have its checkbox property set to true. This being the case switching between the dropdown mode and the checkbox mode would have to be done in the code behind (or perhaps javascript which is not one of my talents). I tried this code

 stringcurrControl = fld.ControlName;

RadComboBoxcmb = (RadComboBox)FindControl(currControl);

cmb.Enabled = true;

if(rule == 3 && fld.Field.Replace("\r\n","") == "PROBLEM_TYPE")

{

 cmb.CheckBoxes==true;

}

The last line: cmb.CheckBoxes==true; throws an error during compilation:

"only assignment call increment decrement and new object can be used as a statement"

Is it that the combobox can be set to checkbox=true in the declaration of the combobox. How can this be done? Any help would be appreciated.

Thanks,

Neil 

Neil
Top achievements
Rank 1
commented on 25 Feb 2022, 10:45 PM

Hi Guys,

   I rarely post but the last time I did I created a ticket with in a day or so after the forum post. I got the impression that you were not thrilled that I had created a forum post and then a ticket within a couple of days. I don't want to  do this again but I am wondering if I will get an answer. If this is not something that can be solved easily, please let me know. I have a  clumsy work around that I can try but I'd like to know if I need to. I know I'm not the only person who is under pressure but If I know there is a reason to wait it makes my decisions easier.

Thanks,

Neil

1 Answer, 1 is accepted

Sort by
0
Doncho
Telerik team
answered on 28 Feb 2022, 08:55 AM

Hi Neil,

The error you get is indicating a compilation error. 

You should use the single equal sign '=' (instead of the double one '==') to assign the new value to the CheckBoxes property:

cmb.CheckBoxes=true;
Please give it a try and let me know how it goes.

Note: Thank you for using our forums prior to submitting formal support tickets! That way our discussions may help other developers facing similar issues. Still, due to our internal policy, the response time for formal support tickets is guaranteed depending on the purchased license package. In all cases (forums and tickets) we do our best to provide assistance as quickly as possible following our queue of open threads.
We admire your current approach, but in case you need a quicker support answer you can use the ticketing system as your first option.

Kind regards,
Doncho
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Neil
Top achievements
Rank 1
commented on 28 Feb 2022, 02:52 PM

Doncho,

   I believe that I owe you an apology for wasting your time. I looked at the rest of code behind that contained the sample code I put in this post and of course there is line after line of code using the single equal sign for linq statements and simple initialization statements. I had what we call in American a brain fart.:-). I hate wasting time or wasting other people's time. So thanks for your patience. I think in addition to the silliness  of using a double equal sign ("==") I was certain that changing the Checkbox property of the Combobox was the problem because I couldn't find an example of setting the property in the codebehind in any of the forum or stackoverflow. A perfect storm of confusion.

Unfortunately I wasted your time. I'm sure this kind of things happens to other people but the only thing anyone can learn from this is to review their code more carefully and to stay alert :-). Thanks for your help. And I will continue to use the forums and not create tickets unless I have a real emergency. Sorry for the fuss.

 Neil 

Doncho
Telerik team
commented on 01 Mar 2022, 09:44 AM

Thanks for the feedback, Neil!

No need to apologize. We face similar issues in our daily work and helping would never be a waste of our time.

Happy coding!

Tags
ComboBox
Asked by
Neil
Top achievements
Rank 1
Answers by
Doncho
Telerik team
Share this question
or