C# Accessing controls from an outside class without "public"
<p>I know this has been asked before but I believe my situation is a bit different -- or I don't understand the answers given.  I have spent about 4 hours working on this solidly and finally realized, I just don't know what to do.</p>

<p>I have 2 Forms (Form1, Settings) and a class I created called Themes.</p>

<p>I have get/set properties that currently work but are all within Form1 and I would like to move as much code related to themeing as I can OUTSIDE of Form1 and into <code>Themes.cs</code>.</p>

<p>Changing Theme:  To change the theme, the user opens up the Settings form and selects a theme from the dropdown menu and presses the 'Set' button -- this all works, but now I want to move it into my own class and I can't get the code to compile.</p>

<p>Here is example code that works before moving -- note that this is only 2 different controls I want to modify but there are about 30 total.  I am abridging the code:</p>

<p>Form 1:</p>

<pre><code>public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void btnSettings_Click(object sender, EventArgs e)
    {
        Settings frm = new Settings(this);
        frm.Show();
    }

    private Color txtRSSURLBGProperty;
    private Color txtRSSURLFGProperty;

    public Color TxtRSSURLBGProperty
    {
        get { return txtRSSURLBGProperty; }
        set { txtRSSURL.BackColor = value; }
    }

    public Color TxtRSSURLFGProperty
    {
        get { return txtRSSURLFGProperty; }
        set { txtRSSURL.ForeColor = value; }
    }
</code></pre>

<p>Settings Form:</p>

<pre><code>public partial class Settings : Form
{
    public Settings()
    {
        InitializeComponent();
    }

    private Form1 rssReaderMain = null;

    public Settings(Form requestingForm)
    {
        rssReaderMain = requestingForm as Form1;
        InitializeComponent();
    }

    private void button2_Click(object sender, EventArgs args)
    {
        // Appearence settings for DEFAULT THEME

        if (cbThemeSelect.SelectedIndex == 1)
        {
            this.rssReaderMain.TxtRSSURLBGProperty = Color.DarkSeaGreen;
            this.rssReaderMain.TxtRSSURLFGProperty = Color.White;
            [......about 25 more of these....]
        }
</code></pre>

<p>The theme class is currently empty.  Again, the goal is to move as much code into the themes class (specifically the get/set statements if at all possible!) and hopefully just use a method similar to this within the Settings form once the proper drowndown item is selected: <code>SetTheme(Default);</code></p>

<p>I hope someone can help, and I hope I explained it right! I have been racking my brain and I need to have this done fairly soon!  Much thanks in advance as I'm sure everyone says.  I have teamviewer or logmein if someone wants to remote in -- that is just as easy.</p>

<p>I can also send my project as a zip if needed.</p>

<p>Thanks so much,</p>

<p>Kurt</p>

<p>Modified code for review:</p>

<p>Form1 form:</p>

<pre><code>public partial class Form1 : ThemeableForm
{

    public Form1()
    {
        InitializeComponent();
    }
</code></pre>

<p>ThemeableForm form:</p>

<pre><code>internal abstract class ThemeableForm : Form
{
    private Color rssLabelBGProperty;
    private Color rssLabelFGProperty;

    public Color RssLabelBGProperty
    {
        get { return rssLabelBGProperty; }
        set { lRSS.BackColor = value; }
    }

    public Color RssLabelFGProperty
    {
        get { return rssLabelFGProperty; }
        set { lRSS.ForeColor = value; }
    }
</code></pre>

<p>Settings form:</p>

<pre><code>    public Settings(ThemeableForm requestingForm)
    {
        rssReaderMain = requestingForm as ThemeableForm;
        InitializeComponent();
    }

    private ThemeableForm rssReaderMain = null;

    private void button2_Click(object sender, EventArgs args)
    {

        // Appearence settings for DEFAULT THEME

        if (cbThemeSelect.SelectedIndex == 1)
        {
            this.rssReaderMain.LRSSBGProperty = Color.DarkSeaGreen;
            this.rssReaderMain.LRSSFGProperty = Color.White;
        }
</code></pre>

<p>Now the all the controls in my get/set (lRSS in the example code above) error out with <code>does not exist in the current context</code>.  I also get the warning:</p>

<blockquote>
  <p>Warning   1The designer could not be shown for this file because none of
  the classes within it can be designed.  The designer inspected the
  following classes in the file: </p>
  
  <p>Form1 --- The base class 'RSSReader_BKRF.ThemeableForm' could not be
  loaded.  Ensure the assembly has been referenced and that all projects
  have been built.      0   0</p>
</blockquote>
