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
944
Programmatically disable an OptionSet Item
posted

Hi,

How can I programmatically disable an Option set value. I dont want to remve it, just disable it.

The reason is that I have 2 Option sets, and selecting a Value in the first set automatically selects a corresponding value in the second one, and makes the other options in the second one unselectable.

Many thanks

Jason

  • 40
    posted

    Hi.

     

    How  Cancel the selection to certain option.

    Example

    I use the ValueChanged, to validate certains conditions, if some it's correct then accept this,

    but it's false to reject the operation, and i need to return the original state of the selecction. 

    • 469350
      Verified Answer
      Offline posted in reply to Jero

      I don't think you can cancel the change. ValueChanged is past tense - it means that value has already changed. So it's too late to cancel. 

      I don't think the OptionSet has an event that fires before the selection changes. You should be able to set the Value or CheckedIndex inside the ValueChanged event to set it back to what it was. But you would have to keep track of the old value and also deal with how to avoid recursion (probably using the EventManager to disable the ValueChanged event while you are in it).  

      • 395
        Offline posted in reply to Ivo Huizinga

        Hi,
        Does anybody know if this feature is going to be added soon.. So many times in our app we disable individual options.  We don't want to remove them, we have coded around it a bit using the example above and some code to stop people clicking the option, but its a bit dirty.  When we disable the item the background goes odd and doesn't conform to the theme and stuff..

        Would be good if this feature is added.

        Regards
        Chris

        • 100
          Offline posted in reply to Mike Saltzman

          I found a way: 

          Dim element As Infragistics.Win.OptionSetOptionButtonUIElement

          element = DirectCast(UltraOptionSet1.UIElement.ChildElements(0).ChildElements(xxx), Infragistics.Win.OptionSetOptionButtonUIElement)

          With element
              .Enabled = False
              .Invalidate()
          End With

          Change xxx for the index of the ValueListItem you want to disable. Item still clickable though :(

      • 469350
        Offline posted

        Hi Jason,

            I don't think you can. There's no enabled property on the items. You would have to remove the item.

             You should also Submit a feature request to Infragistics

        • 944
          Verified Answer
          posted in reply to Mike Saltzman

          Thanks Mike,

          I have worked out a solution for now, simply some validation which will not allow the user to select certain options depending on the other options selected. Just using a popup message advising the user and then unselecting the option they chose.

          I will submit my preferred functionality as a feature reqest.

          Many thanks

           

        x An error occurred. Please try again or contact your administrator.
        x An error occurred. Please try again or contact your administrator.