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

Overriding Events

3 Answers 99 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Kenneth Jackson
Top achievements
Rank 1
Kenneth Jackson asked on 04 Aug 2008, 09:05 AM
I wish to implement custom behavior on a form with a ribbon bar when the
form is minimised.

It's easy enough to trap the events of the minimise , maximise and close buttons -
However , I am unable to replace these events with those of my own .
In other words I want to be able to implement behavior to the minimise
buttons' click event and stop the minimise button from doing anything else
by default.

I initially looked at the routedeventbehavior class and related classes but cannot
find any code examples on how to use these correctly.

3 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 05 Aug 2008, 08:27 AM
Hello Kenneth Jackson,

Thank you for contacting me.

I am not sure if I understand the details of your scenario. Still, you could implement your custom code when the form is minimized using Form.SizeChanged event:
void Form1_SizeChanged(object sender, EventArgs e) 
    if (this.WindowState == FormWindowState.Minimized) 
    { 
        //Your custom code        
    } 

You cannot cancel minimizing the form when the minimize button is clicked. You could only hide the button element and in this way prevent the user to minimize the form:
(this.radRibbonBar1.RibbonBarElement.Children[0].Children[1].Children[1].Children[0].Children[0] as RadButtonElement).Visibility = Telerik.WinControls.ElementVisibility.Hidden; 

If you have other questions, do not hesitate to contact me again.

Best wishes,
Martin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Kenneth Jackson
Top achievements
Rank 1
answered on 05 Aug 2008, 08:38 AM
Thanks for your response,
stopping the minimise event from happening is exactly what I wanted to do while being notified that the user had clicked the minimise button.

For the purpose of other ribbonbar users who may want to do the same,
what I did do is - I created a RadButtonElement called oMinimiseButton(declared withevents) and in the form_load event I set its Image property to the image property of the minimise button on the ribbonbar.

I then removed the minimise button of the ribbonbar and added oMinimiseButton to the same collection. This worked perfectly and I'm
able to trap the minimise buttons' click event and override the "minimise behavior" completely.

Ofc you can do the same for the close and max buttons should you want to override the behaviors there also.

0
Martin Vasilev
Telerik team
answered on 06 Aug 2008, 11:59 AM
Hi Kenneth,

Thank you for sharing your approach with us. I am glad to see that you have found a solution that suits your scenario.

If you need additional assistance, do not hesitate  to contact me again.

Best wishes,
Martin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
RibbonBar
Asked by
Kenneth Jackson
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Kenneth Jackson
Top achievements
Rank 1
Share this question
or