Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Control 1

Status
Not open for further replies.

figler

Programmer
Dec 26, 2001
155
US
Code:
Public Class QVW
    Inherits System.Windows.Forms.ListView

I am trying to save myself some time by creating a new control that wraps the windows listview control. I would like for this control to offer all the functionality of the listview, but with a few extra methods and properties.

The problem is that the methods and properties that I am adding make use of the built-in functionality of listview, and in my class the only methods and properties that are available for "QVW" are those that are 'shared' or 'class'.

What's the best way to do this? As an example (just to demonstrate what I want to do), let's say that I want to make a method that will add a column. My code might look something like this:

Code:
Private Sub MakeColumn()
   QVW.ColumnHeaderCollection.Add("ExtraColumn")
End Sub

But VS is giving me the following error:
Reference to a non-shared member requires an object reference

I understand the error, but I feel like this is a pretty common thing to do in OOP and so I'm hoping one of you guys can tell me how this is typically handled.

Thanks.

-Brad
 
Don't know how to do it in VB.NET, but in C# you would refer to the "this" member, to refer to the current instance of the object, instead of the class name (QVW).

Chip H.
 
Chip, you're a lifesaver -- the equivalent of "this" in VB is "me". Much appreciated!!! -- I should have known that!!!
 
I knew about the "Me" keyword, but I thought it was one of the things that went away in the VB6 to VB.NET transition.

Glad to help.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top