Change MenuStrip Rendermode runtime

  • Thread starter Thread starter HansvB69
  • Start date Start date
H

HansvB69

Guest
Hi,

I want to change the color of some components on a form. It seems that i can not access the menustrip Rendemode. (I don't want to set i direct in the Property window of the designer).
how can i access the menustrip rendermode?
See the "--> this is not allowd ???" This is the part that doesn't work


What am i missing?


error message:

Error CS1061 'Control' does not contain a definition for 'RenderMode' and no accessible extension method 'RenderMode' accepting a first argument of type 'Control' could be found (are you missing a using directive or an assembly reference?)




using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace TopData
{
public class ApplicationColor
{
private byte R; //99
private byte G; //108
private byte B; //135


public ApplicationColor(byte ColorRed, byte ColorGreen, byte ColorBlue)
{
this.R = ColorRed;
this.G = ColorGreen;
this.B = ColorBlue;
}


public void SetFormColor(Form frm)
{
try
{
if (frm != null)
{
frm.BackColor = Color.FromArgb(R, G, B); //Form back color

foreach (Control c in frm.Controls)
{
if (c is MenuStrip)
{
c.BackColor = Color.FromArgb(R, G, B);
c.ForeColor = Color.White;
c.RenderMode = ToolStripRenderMode.System; --> this is not allowd ???
c.Renderer = new ToolStripProfessionalRenderer(new MenuColorTable());--> this is not allowd ???

}

if (c is StatusStrip)
{
c.BackColor = Color.FromArgb(R, G, B);
}

if (c is Panel)
{
c.BackColor = Color.FromArgb(R, G, B);
}
}
}
}
catch (Exception ex)
{
//TODO...
}
}

}
}

Continue reading...
 
Back
Top