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

ReadOnlyChanged

1 Answer 53 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
konrad
Top achievements
Rank 1
konrad asked on 28 Jan 2016, 09:34 AM

Hi,

I have a problem with RadRadioButton and RadToggleSwitch.

I would like to change the look of the control depending on the ReadOnly state.

But I can not find an event ReadOnlyChanged

I also try to catch all property changes, but no event is registered when I change the ReadOnly.

((Telerik.WinControls.UI.RadRadioButtonElement)(x.GetChildAt(0))).RadPropertyChanged += ...
((Telerik.WinControls.UI.CheckBoxLayoutPanel)(x.GetChildAt(0).GetChildAt(1))).RadPropertyChanged += ...
((Telerik.WinControls.Layouts.ImageAndTextLayoutPanel)(x.GetChildAt(0).GetChildAt(1).GetChildAt(0))).RadPropertyChanged += ...
((Telerik.WinControls.UI.RadRadiomark)(x.GetChildAt(0).GetChildAt(1).GetChildAt(1))).RadPropertyChanged += ...
 
((Telerik.WinControls.UI.RadRadioButtonElement)(x.GetChildAt(0))).PropertyChanged += ...
((Telerik.WinControls.UI.CheckBoxLayoutPanel)(x.GetChildAt(0).GetChildAt(1))).PropertyChanged += ...
((Telerik.WinControls.Layouts.ImageAndTextLayoutPanel)(x.GetChildAt(0).GetChildAt(1).GetChildAt(0))).PropertyChanged += ...
((Telerik.WinControls.UI.RadRadiomark)(x.GetChildAt(0).GetChildAt(1).GetChildAt(1))).PropertyChanged += ...
 
item.PropertyChanged += ...

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 28 Jan 2016, 12:25 PM
Hello Dominik,

Thank you for writing.

Indeed, there is no notification for changing the ReadOnly property of the mentioned controls. However, you can create your own property which will affect the ToggleSwitchElement.ReadOnly property and raise your custom event. You can find below a sample implementation of a custom RadToggleSwitch:
public Form1()
{
    InitializeComponent();
 
    this.radToggleSwitch1.ReadOnlyChanged += radToggleSwitch1_ReadOnlyChanged;
}
 
private void radToggleSwitch1_ReadOnlyChanged(object sender, ReadOnlyEventArgs e)
{
    Console.WriteLine(e.ReadOnly);
}
 
private void radButton1_Click(object sender, EventArgs e)
{
    this.radToggleSwitch1.MyReadOnly = !this.radToggleSwitch1.MyReadOnly;
}
 
public class MyToggleSwitch : RadToggleSwitch
{
    public event EventHandler<ReadOnlyEventArgs> ReadOnlyChanged;
 
    protected virtual void OnReadOnlyChanged(bool readOnly)
    {
        if (ReadOnlyChanged != null)
            ReadOnlyChanged(this, new ReadOnlyEventArgs(readOnly));
    }
     
    public bool MyReadOnly
    {
        get
        {
            return this.ToggleSwitchElement.ReadOnly;
        }
        set
        {
            this.ToggleSwitchElement.ReadOnly = value;
            OnReadOnlyChanged(this.ToggleSwitchElement.ReadOnly);
        }
    }
 
    public override string ThemeClassName
    {
        get
        {
            return typeof(RadToggleSwitch).FullName;
        }
    }
}
 
public class ReadOnlyEventArgs : EventArgs
{
    public ReadOnlyEventArgs(bool readOnly)
    {
        ReadOnly = readOnly;
    }
 
    public bool ReadOnly { get; private set; }
}

I hope this information helps. Should you have further questions I would be glad to help.
 
Regards,
Dess
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Buttons, RadioButton, CheckBox, etc
Asked by
konrad
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or