TechArena Community

TechArena Community (http://forums.techarena.in/)
-   Software Development (http://forums.techarena.in/software-development/)
-   -   Problem with inherits listview in a class component (http://forums.techarena.in/software-development/1264344.htm)

Abdullah30 28-10-2009 11:50 PM

Problem with inherits listview in a class component
 
I have a Visual basic.net containing 3 project:
- The main windows
- Classes
- The user controls (CTRLUser)

I want to add in CTRLUser a "class component" (LVGreen) inheriting a ListView classic. So I:
Code:

Public Class LVGreen
    Inherits ListView
End Class

Now I have this error:

Quote:

Type 'ListView' undefined.
How to fix this error?

fellah 28-10-2009 11:51 PM

Re: Problem with inherits listview in a class component
 
Code:

Public Class LVGreen
    Inherits System.Windows.Forms.ListView
End Class


Abdullah30 28-10-2009 11:52 PM

Re: Problem with inherits listview in a class component
 
Already tried that but got this error:

Quote:

The base class 'System.Windows.Forms.ListView' specified for class 'LVGreen' can not be different from the base class 'System.ComponentModel.Component' of one of its other partial types.

$tatic 28-10-2009 11:54 PM

Re: Problem with inherits listview in a class component
 
Your custom control is actually split into 2 files:
- LVGreen.vb, you can freely modify
- LVGreen.designer.vb used by the designer (by default it is hidden within Visual)
The class LVGreen is divided into 2 parts through the technique of "partial classes"

But it requires that different parts of the class defines all the same inherited class, or in the file designer.vb it is said that the class inherits from Component. It is therefore necessary that you change this file (it is usually never change) to set ListView instead of Component

Incidentally, it is a little weak as the base class is declared in the designer.vb, since it prevents the developer to modify (well, to change easily). I suppose it reflects the will of Microsoft to make Visual Basic as a language "easier" by hiding the complexity of the developer. In C# the base class is declared in the file that the user can edit, which is still more logical.


All times are GMT +5.5. The time now is 08:41 PM.