Shadows again, Databound listview article

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nic

    Shadows again, Databound listview article

    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
    DataColumnHeade rCollection
    Get
    Return mColumns
    End Get
    End Property

    Thanks,
    Nic
  • Jon Skeet [C# MVP]

    #2
    Re: Shadows again, Databound listview article

    Nic <newsgroup.emai l@pandora.be> wrote:[color=blue]
    > 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.[/color]

    <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 DataColumnHeade rCollection Columns
    {
    get { return mColumns; }
    }

    But to repeat, that *isn't* overriding. That's hiding, which is very
    different.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • Austin Ehlers

      #3
      Re: Shadows again, Databound listview article

      Quick note,
      C# VB.NET
      new Shadows
      override Overrides
      abstract MustOverride
      sealed NotOverridable

      HTH,
      Austin Ehlers

      Comment

      Working...