Skip to content

Accessibility problem

Gareth Morris

Asked Aug 9, 2006, 6:21 PM EDT1 answer
Share
LinkedInX
Hi,

I'm pretty new to the the forum. I think this would be my first post in as long as I've been here. I'm having problems accessing a List of custom tabs that I extended from the TabPage class. It didn't throw a wobbler until I changed a piece of code at which point my Visual Studio decided to throw a wobbler and die as well, so I lost the ability to undo/redo. It worked well until I changed the code to pass it another integer (which I initially made a reference to the "allBrowserTabs" list but then thoguht, I'll stick to something simple) but still couldn't get it to compile.

The error I get is:

Error 1 Inconsistent accessibility: parameter type 'System.Collections.Generic.List' is less accessible than method 'Spring_Map_Generator.SimpleMessageForm.SimpleMessageForm(System.Collections.Generic.List, int, System.Windows.Forms.TabControl)' C:\Documents and Settings\Gareth\My Documents\Visual Studio 2005\Projects\Spring Map Generator\Spring Map Generator\SimpleMessageForm.cs 19 16 Spring Map Generator

I've read a number of articles on this and got the general gist of what's wrong, but in my own code I can't work out what's causing the difference in levels of accessibility. Is it anything to do with the fact that "allDevTabs" is a static variable in RootForm? It shouldn't be because it compiled before trying to send a second list through the constructor...

CLASS A:
namespace Spring_Map_Generator
{
public partial class SimpleMessageForm : Form
{
// Required for adding a new tab to the main form.
List allDevTabs;
int browserListSize = 0;
System.Windows.Forms.TabControl TabControl;


// Set up the form. (Constructor)
public SimpleMessageForm(List devTabs, int newBrowserListSize, System.Windows.Forms.TabControl newTabControl)
{
allDevTabs = devTabs;
browserListSize = newBrowserListSize;
TabControl = newTabControl;
InitializeComponent();
}

}

}

CLASS B:
namespace Spring_Map_Generator
{
public partial class RootForm : Form
{
// Create static vars
FileManagement ioManager = new FileManagement();
DefinitionLibrary defs = new DefinitionLibrary();
int OptionsPanelWidth = 120;
bool changesMade = false;

// Add a list of all the currently open TabPages
List allDevTabs = new List();
List allBrowserTabs = new List();

// Constructor
public RootForm()
{
InitializeComponent();
defs.SetOutput(Output);
}

...

...

// Open up a new form in order to create a new file (and a new DevTab)
private void fileToolStripMenuItem1_Click(object sender, EventArgs e)
{
SimpleMessageForm createNewFileForm = new SimpleMessageForm(allDevTabs, allBrowserTabs.Count, TabControl);
createNewFileForm.Show();
}

}
}

Any ideas as to what I've done?

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    I managed to fix it. The problem lay not in either of these classes described above but in the DevTab class itself. The DevTab class differed in accessibility in that it wasn't public and the constructor in the simple form class required it to be. The fix was to make the entire DevTab class, the class I was passing and not an instance of the class, public.

    public class DevTab : System.Windows.Forms.FileTab{

    }

    Lovely :)
    0