Shadows again, Databound listview article

  • Thread starter Thread starter Nic
  • Start date Start date
N

Nic

Hi,

The original creators of the ListView control never
envisioned that we'd want to override the Columns
property with our own version, so they didn't mark it as
Overridable. This means we can't simply override the
property. Fortunately, we can use the Shadows keyword to
override a method even when it wasn't designed that way.

Thats is possible in VB.NET.

What do I have to do in C#?

The VB code is :
Public Shadows ReadOnly Property Columns() As
DataColumnHeaderCollection
Get
Return mColumns
End Get
End Property

Thanks,
Nic
 
Nic said:
The original creators of the ListView control never
envisioned that we'd want to override the Columns
property with our own version, so they didn't mark it as
Overridable. This means we can't simply override the
property. Fortunately, we can use the Shadows keyword to
override a method even when it wasn't designed that way.

<snip>

I *very* much doubt that that's really overriding the method, given
what I understand of VB. I suspect in this case all you need is new:

public new DataColumnHeaderCollection Columns
{
get { return mColumns; }
}

But to repeat, that *isn't* overriding. That's hiding, which is very
different.
 
Quick note,
C# VB.NET
new Shadows
override Overrides
abstract MustOverride
sealed NotOverridable

HTH,
Austin Ehlers
 
Back
Top