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
690
howto get readonly-changed event of any infragistics control?
posted

I learned from other posts that I simply have to change appearance.backcolor if I want to change the backcolor of a control with readonly=true.

As some controls are set to readonly at design time, others at runtime based on conditions, I to not want to have spread any if..then...elses all over my code where I might need it, but to register a "read only changed" event on each control (I loop them anyway, to set all kind of layout (format strings, tooltips etc)

Can this be achieved with the property_changed event?

I'd like to

public void readonly/property_changed(object sender, eventargs e){

if (sender.readonly)

   sender.backcolor=some defined color;

else

   sender.backcolor=white;

}

  • 23930
    Verified Answer
    Offline posted

    Hi,

    Thank you for posting in our forums.

    All our controls have a PropertyChanged event, which can be used for this task. Keep in mind that not all of our controls define readonly property. For example the UltraGrid uses different properties, to specify whether its cells can be edited. Still if you are using editors, this event will be useful for you. The event arguments have a PropID member, which shows what property was changed. This way you can detect that the control’s ReadOnly property was changed. After that you will have to determine what the control type is and cast it to this type in order to set the appearance (none of our base types / interfaces has an Appearance property, so you need a concrete type). Alternatively you can use reflection to check if the sender has an Appearance property and if it has to set it to the desired appearance.

    I have attached a sample demonstrating the reflection approach. The buttons on the form change the readonly property of the above editors.

    Please let me know if you have any additional questions.

    WE_ReadonlyBackColor.zip