user415789
user415789

Reputation:

Inherited Control from base Form class not working properly

I have FormBase and MainForm : FormBase.

FormBase Contains a DataGridView dgv. in designer view of FormBase dgv font sizes are fine but in designer view and runtime in MainForm they are default values. why and what should I do??!

Upvotes: 0

Views: 316

Answers (3)

Hans Passant
Hans Passant

Reputation: 941635

The designer for DVG doesn't support designing the control in an inherited form, a limitation of many designers of controls that were added in .NET 2.0. The Font property is an 'ambient' property, it gets the same value as the parent unless you've explicitly selected one (shown in bold in the Properties window). So either set the form's Font property to also change the DGV font or change the Font property of the DGV in the base form.

Upvotes: 1

k.m
k.m

Reputation: 31454

To clarify my comment: putting UI (together with DataGridView) from BaseForm in custom user control and using it separately on previously inheriting forms will surely fix the font problem.

If your base form is only "container" for commonly used controls (so you don't have to put 3 buttons, datagrid and label on every window) or defines some basic layout - go with custom user control.

Here's decent starting point if you want to explore this topic - Custom User Controls.

Upvotes: 0

Related Questions