Inconsistent accessibility: field type 'myListView' is less accessible than field 'mainForm.myListView2'

Posted on 2008-11-10
Last Modified: 2012-05-05
I have a main form where I have built a listview (public) using the VS IDE (MS VS C# Express 2008).  I have a class that is trying to reference that listview, but I'm gettting the above error.

What exactly does this mean, and how do I fix it?
Question by:rmmarsh
    LVL 2

    Expert Comment

    This means that one class is declared as "Public" and another class has been declared as "Private" or "Internal"
    LVL 18

    Expert Comment

    Declare myListView as public

    Author Comment

    MyListView is public... 

    Author Comment

    The listview is in the main form which is also public... I have attached code snippets...
                    //  now, present the data...
                    mainForm mf = new mainForm(false);  //  don't show the splash screen or do any other initialization
                    int i = 0;
                    foreach (object obj in alData)
                        ListViewItem lvi = new ListViewItem(alData[i].ASIN);
                        mf.myListView2.Tag = "Title";
                        mf.myListView2.Items.Add(lvi);  // Add the list items to the ListView

    Open in new window

    LVL 2

    Expert Comment

    What is the declaration for mf.myListView2?  

    Is myListView2 a public property?

    Author Comment

    myListView2 is public... (        public myListView myListView2;)  <- taken from mainform.designer.cs


    Accepted Solution

    I have figured it out myself:  if I pass the listview to the class method, I can get around the addressability propblems.
    Thanks everyone for your help...

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now