Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 246193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:09:07+00:00 2026-05-11T21:09:07+00:00

Lets say I inherit a class, that has several public properties and/or methods, however

  • 0

Lets say I inherit a class, that has several public properties and/or methods, however I do not want them to be public properties/methods of my class – in other words, I want to make those properties protected properties of my class.

Can this be achieved?

I hope I was clear enough, if not please let me know, will try to explain myself better.

EDIT:

Right, thank you all for answers however I don’t think I was clear enough. What I am trying to accomplish is this:

I wrote a windows control that extends ListView control. ListView has a public collection Items, that can be modified. That’s all fine, however I wrote new methods for adding items to listview because of the extra data I need.

It all works great so far, however the Items collection can still be modified by anything, which is a problem, because if an item is added by direct manipulation of Items collection not all data I need is gathered, thus causing an error.

Since we hope to reuse this control several times in different projects, we are afraid that sooner or later, the default way of adding items to Items collection will be used (just a matter of time really). We are just looking for a way to prevent that from happening, like throwing an exception when Items collection gets bigger, but the way it was intended.

I hope this all makes sense now.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T21:09:07+00:00Added an answer on May 11, 2026 at 9:09 pm

    Never say never. This is probably not the best idea but it seems to work for me. This hides items by re-implementing it in the subclass and then hiding it using attributes. I added in a “CustomExposedItems” property so you can see that the existing items are still accessible in the underlying ListView.

    public partial class CustomListView : ListView
    {
        public CustomListView()
        {
            InitializeComponent();
        }
    
        public System.Windows.Forms.ListView.ListViewItemCollection CustomExposedItems
        {
            get
            {
                return base.Items;
            }
    
        }
    
        [EditorBrowsable(EditorBrowsableState.Never)]    
        [Browsable(false)]    
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        [Obsolete("Use the new custom way of adding items xyz")]
        public new System.Windows.Forms.ListView.ListViewItemCollection Items    
        { 
            get { throw new NotSupportedException(); }    
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So let's say I have two classes that inherit a base class that has
Lets say I have one table called REVIEWS This table has Reviews that customers
Alright lets say I have a cPlayer class that inherits from cOrganism , which
Lets say I have a java package commands which contains classes that all inherit
Lets say I have a controller class like this. public class InStorePickupController : Controller
Lets say I have a site that has a Layout with navigation. This navigation
Lets say I have a class A that inherits from class B in C#.
I have two objects that are derived from same the base class. Lets say
Lets say I have a two classes: class A : public QObject {}; class
Lets say I have a listener interface defined as: class Listener { public: virtual

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.