Common methods for all RadForms

2 Answers 79 Views
General Discussions Themes and Visual Style Builder
Ian
Top achievements
Rank 2
Bronze
Iron
Iron
Ian asked on 24 Nov 2021, 02:24 PM

I'm currently migrating a 160-form application to the latest Telerik framework, and I need to do some processing which is common to all forms:

- checking for, and applying a user-saved theme

- positioning the form where the user last saved it.

I could implement a method call in the _load event for each form, but I wonder if there is a better way. Maybe a kind of 'load' event which applies to all forms. Or some way to modify RadForm - whilst still making the Designer work.

Does anyone have a soltion for this which is neater than adding a method call in each of 160 forms (and remembering to do it for any ones) ?

2 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Nov 2021, 02:58 PM
Hello, Ian, 

Since RadForm is a derivative of the standard MS Form, it offers the same events as the Form class, e.g. Load and Shown events. The Load event is an appropriate place if you need to perform any logic to the form itself and thus use the same approach for all forms that needs to have this code executed. 

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Ian
Top achievements
Rank 2
Bronze
Iron
Iron
answered on 25 Nov 2021, 12:26 PM

I didn't explain very well...

What I'm asking about is a way to code a "load" event handeller which is called when any form in the application is loaded, a kind of "when ANY form is loaded, do this.." method.

I know I can write a 'setupForm() method, and create a handler in every form which handles the 'load' event and calls 'setupForm()'  - i guess i'm trying to see if there is any way to avoid doing this 160 times.

Dess | Tech Support Engineer, Principal
Telerik team
commented on 29 Nov 2021, 02:43 PM

Hi, Ian, 

This seems more like a general programming question than related to the Telerik UI for WinForms suite. However, I can give a suggestion how to handle this situation. It is possible to use the Application.OpenForms and iterate all of them, then execute one common method that executes the desired action.

Ian
Top achievements
Rank 2
Bronze
Iron
Iron
commented on 01 Dec 2021, 04:53 PM

OK. I was hoping that maybe your framework had some secret way of doing this.!

No problem - just a lot more typing...

Tags
General Discussions Themes and Visual Style Builder
Asked by
Ian
Top achievements
Rank 2
Bronze
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Ian
Top achievements
Rank 2
Bronze
Iron
Iron
Share this question
or