OK button event

4 posts, 1 answers
  1. Smiljan
    Smiljan avatar
    8 posts
    Member since:
    Mar 2015

    Posted 30 Mar 2015 Link to this post

    Hi!

    I modified appointment edit/insert form with my own custom fields.

     Everything works OK (saves all the extra data in my custom fields), but I've added extra button on the form and I need to "tap into" default save event.

     For example - default OK button saves data from all controlls to database. I want for the new button to do the same, but in the process I write some new vaules in my custom fields and for that I need new button (which would set new values in certain controls and default save event would then save alltogether - "ApplySettingsToEvent").

    Thank you for any kind of info.

    BR, Smiljan
  2. Answer
    Dess
    Admin
    Dess avatar
    1609 posts

    Posted 02 Apr 2015 Link to this post

    Hello Smiljan,

    Thank you for writing.

    In order to perform the same logic as the OK button in your custom button's Click event you can call the EditAppointmentDialog.buttonOK.PerformClick method:
    public partial class CustomAppointmentEditForm : EditAppointmentDialog
    {
        public CustomAppointmentEditForm()
        {
            InitializeComponent();
        }
     
        private void radButton1_Click(object sender, EventArgs e)
        {
            this.buttonOK.PerformClick();
        }
    }

    I hope this information helps. Should you have further questions, I would be glad to help.
     
    Regards,
    Dess
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Smiljan
    Smiljan avatar
    8 posts
    Member since:
    Mar 2015

    Posted 03 Apr 2015 in reply to Dess Link to this post

    Hi!

    Works great!
    It's worth to mention that if you set default (inherited) OK button to Enbled=false, then also buttonOK.PerformClick method won't fire.
    In this case you have to use Visible=False insetad Enabled=False.

    Tnx again.
    BR, Smiljan
  5. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 07 Apr 2015 Link to this post

    Hello Smiljan,

    Thank you for writing back.

    It is desired behavior when a RadButton is disabled and calling the PerformClick method does not fire its Click event. As you have already found out, you should hide the RadButton instead of disabling it.

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top