Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
918
Disable combo
posted

I have several combo's on my form and want to quickly enable or disable the group. I tried the following code but it doesn't work. 

Dim combo As Infragistics.Win.UltraWinEditors.UltraComboEditor

For Each combo In Me.Controls

combo.Enabled = False

Next

I have the code in the formload event. When it runs it jumps out of the form load event at this line "For Each combo In Me.Controls" and goes to the splitter control_splitter moved event. from there it goes back to the .show on the previous form and I get this error:

Unable to cast object of type 'System.Windows.Forms.SplitContainer' to type 'Infragistics.Win.UltraWinEditors.UltraComboEditor'.

What am I doing wrong.

thanks

  • 469350
    Verified Answer
    Offline posted

    Me.Controls  most likely contains many controls that are not UltraComboEditors, so this is probably raising an exception which is being caught.

    What you should do it use a variable of type Control for your loop, then check each Control to see if it is an UltraComboEditor inside the loop.