I'm pretty new to VB and I want to inherit from DataGridView
, I use something like
Public Class DataGridViewEx Inherits DataGridView
End Class
But compiler generates an error as End of statement expected
pointing to Inherits DataGridView
. What is wrong and how I should do this?
In visual basic, it's not possible to inherit the base class constructors in the derived class and the accessibility of other members of the base class also depends on the access modifiers which we used to define those members in the base class.
Visual Basic introduces the following class-level statements and modifiers to support inheritance: Inherits statement — Specifies the base class. NotInheritable modifier — Prevents programmers from using the class as a base class. MustInherit modifier — Specifies that the class is intended for use as a base class only.
Inheritance is a feature or a process in which, new classes are created from the existing classes. The new class created is called “derived class” or “child class” and the existing class is known as the “base class” or “parent class”. The derived class now is said to be inherited from the base class.
What is Inheritance in VB.Net? Inheritance can be defined as the feature of the programming language that offers an opportunity to make the use of functions that are already defined in a base class. In Inheritance, the base class is the class which passes its functionality to other class.
Put it in the next line:
Public Class DataGridViewEx
Inherits DataGridView
End Class
MSDN: Inherits
If used, the Inherits statement must be the first non-blank, non-comment line in a class or interface definition. It should immediately follow the Class or Interface statement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With