Reputation: 21
I am working on one assignment to Create a user control inheriting a text box which would allow only capital alphabets. i am still working with it. below is the code which i have worked till now.
Imports System.ComponentModel
Imports System.Windows.Controls
Partial Public Class textboxupper_uc
Inherits TextBox
Dim strUpperText As String
Sub New()
InitializeComponent()
End Sub
Public Property uppText As String
Get
Return strUpperText
End Get
Set(value As String)
strUpperText = value.ToUpper
End Set
End Property
End Class
the line Inherits TextBox giving error as "Base class "TextBox" specified for class 'textboxupper_uc' can not be different from the base class 'user control' of one of its other partial types."
Upvotes: 0
Views: 540
Reputation: 54487
You need to understand the difference between a user control and a custom control. If you want to inherit the TextBox
class then that is a custom control. A user control is literally a class that inherits UserControl
.
If you added a user control to your project then you have two code files containing partial classes. The designer code file contains Inherits UserControl
and that's why you get that error message. Your class cannot inherit both UserControl
and TextBox
.
You don't actually want a user control so delete that item from the Solution Explorer. You want a custom control, you should add a class item to your project rather than a user control. In the class definition in the single code file, you can then add Inherits TextBox
and you're good to go.
Upvotes: 1