Serge
Serge

Reputation: 653

Prevent parent event from propagating to child

I have a form which contains a bunch of controls. When I change the form font, the font change event propagates to the children. That is the desired behavior except for the datetimepicker control, where I do not want the font change to trigger. Is it possible to prevent it, or do I have to set the font back to the original after the change is complete?

Upvotes: 0

Views: 406

Answers (2)

stuartd
stuartd

Reputation: 73253

If you explicitly set the font on your DateTimePicker, it will not change when the form font changes. (assuming WinForms)

Upvotes: 1

LBushkin
LBushkin

Reputation: 131726

I assume you're using WinForms - where property inheritance is the normal behavior. The only reliable way to control the font on a particular child is to set it explicitly, as you indicate.

In newer UI frameworks, like WPF, you can use styles and templates to control the appearance of controls. But this is not available in WinForms.

Upvotes: 2

Related Questions