How to subclass c# controls

BenTam-3003 686 Reputation points
2022-06-28T14:19:57.54+00:00

Dear All,

Could anybody tell me how to subclass a c# control?

TIA

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,648 questions
{count} votes

Accepted answer
  1. Karen Payne MVP 35,386 Reputation points
    2022-06-28T15:33:26.123+00:00

    Here are some examples

    215851-f1.png

    Then there are components, for instance, there is no BindingNavigator in .NET Core (at least in VS2019) so we can expose it as follows.

    using System.Windows.Forms;  
      
    namespace WindowsControlLibrary.Classes  
    {  
        /// <summary>  
        /// VS2019 there is no BindingNavigator, here you go :-)  
        /// </summary>  
        public class CoreBindingNavigator : BindingNavigator  
        {  
            public CoreBindingNavigator()  
            {  
                AddStandardItems();  
            }  
        }  
    }  
    
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Castorix31 83,206 Reputation points
    2022-06-28T14:34:57.22+00:00

    You can do like : How to: Inherit from Existing Windows Forms Controls

    (or also SetWindowSubclass with P/Invoke for existing controls, like in C++)

    0 comments No comments