Click here to Skip to main content
15,886,795 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Im using VB.net Winforms and want to inherit a button, to make it resizable for the end-user, the code I have works great (found elsewhere) and is below.

So start off with blank winforms, Form1, right click on Solution, Add User Control, then open up the Designer Code of that code, scrub the Public Class UserControl1 and replace it with the following code;

Partial Class ResizableButton
  Inherits Button
  Protected Overrides ReadOnly Property CreateParams As System.Windows.Forms.CreateParams
    Get
      Dim CP As CreateParams = MyBase.CreateParams
      CP.Style = CP.Style Or &H40000
      Return CP
    End Get
  End Property
End Class



Save, compile, and there is now a new control in your toolbox called Reizable Control.

Run the vb app and you can now resize (as an end-user) the control on the form. Great. Fantastic. Whoohoo.

But - my button has this ugly butt user control surrounding my button - I dont want that, I want "a button".

Ive tried looking for this but im not seeing any mention in any tutorials on inheriting controls on how to get rid. Please help :)

What I have tried:

Searching the internet, reading up on Inheritance but no mention of this space between a Usercontrol and an inherited control
Posted
Updated 4-Jul-19 2:24am

1 solution

Because you have said it should: Window Styles - Windows applications | Microsoft Docs[^] Look at the bit you add to the style (WS_SIZEBOX).
 
Share this answer
 
Comments
Member 12561559 4-Jul-19 9:43am    
Thanks Griff, thank you very much. I will read up on those styles to see what else I can get from them. Cheers. Carl.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900