How to set the default size of a custom control in C#

I altered this custom button for NETCF: http://www.codeproject.com/cs/miscctrl/PocketPCColourBtn.asp

For some reason, which I cannot figure out, when you add a new button to a form the default size is always 200 x 200 pixels. I've opened up all files in the entire package in Emacs and searched for the string "200". I got no relevant hits. Is that size inherited from System.Windows.Forms.Control How do I set a new default size I tried to do it in the constructor with no luck.

/Lars



Answer this question

How to set the default size of a custom control in C#

  • Cem DEMiRKIR

    Are you using NETCF1 or NETCF2

  • jam281

    Windows CE 5.0 with Compact Framework 2.0
  • RoobyDoo

    Try setting size in OnHandleCreated override (haven't tried it myself)

  • Aaron Oneal

    Error 3 'ColourControls.ColourButton.OnHandleCreated()': no suitable method found to override C:\Proj VS 2005\Bromma\GUIet\Rund Knapp - Custom control - AdvButton\ColourControls\ColourButton.cs 200 29 ColourControls

    protected override void OnHandleCreated()
    {
    Width = 50;
    Height = 50;
    }


  • How to set the default size of a custom control in C#