How do I get a .NET TextBox to implement MY OWN INTERFACE
This is a tough one. I know how to use and implement interfaces from my own classes, but how do I take a system.windows.forms.textbox and get it to implement an interface that I designed. I really don't want to have to inherit a textbox into a usercontrol and then do it from there... isn't there a more direct means to do it? I have tried creating an empty class file and making it look like the following...
===================================
Imports System.Windows.Forms
Public Class MyCustomTextBox
Inherits ...
Implements MyOwnInterface
End Class
==================================
and this is where it bombs... when I get the intellisense listing after I type the word Inherits, it doesn't even show System.Windows.Forms as an available choice in the list. It's a very limited subset of the framework. So does anyone know how I can take an existing windows control and get it to use MY INTERFACE?
Thanks a lot, and I wish I could reward the winning answer with $2,000,000 dollars, but a simple "You are Godlike" will have to do.
Forget about intelisense, just write it down ! In C#
public class MyTextBox: System.Windows.Forms.TextBox, IComparer {
}
Hmmm, interesting that it works for you C# folk. Unfortunately I am in VB.NET, where it doesn't. If anyone has a VB.NET Example, that would be great. And please try it yourself before saying it works so you can see the problem I am encountering.
Thanks guys.
public class MyTextBox: System.Windows.Forms.TextBox, IMyInterface {
}
The above code in C# is equivalent to following code in VB.Net
Public Class MyTextBox
Inherits System.Windows.Forms.TextBox
Implements ImyInterface End
ClassI like working on both languages :))
OK, I am 99.7% sure I figured it out. The problem, as is so often the case, is that the most obvious solution is the least checked and least thought of. I was creating a visual studio class library as a project type, then I began with an empty class definition and wondered why adding "Inherits ... " was not providing intellisense for textboxes, checkboxes, and whatever else I wanted to inherit from. Well a huge DUHHHHH makes this plainly obvious. When you start with a "Class Library" as a project type, your project has no reference to Windows.Forms, so even using Imports System.Windows.Forms is not going to do a dang thing. You STILL have to go to references and add the reference. That being done, you have full access to all the windows forms components.
See what happens when the obvious is examined... solutions are found.