Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Inheriting from a Control

$
0
0

Hi folks,

I am trying to create a library of custom controls by inheriting from existing windows Controls. The Control I would like to inherit from first is the Windows pushbutton.

I have managed to create the new class. However I want to change the default font to Arial.

Here is my code:

namespace JPNControls
{
    public partial class JPNbutton : Button
    {
        public JPNbutton()
        {
            InitializeComponent();
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);
            b.Dispose();
        }
    }
}

Whereabouts do I set the font to Arial ? I have tried using  this.font, base.font all without success. Once I know how to achieve this on a button, I should be able to to repeat on all the other controls in the library.

Thanks,

John


jppnn


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>