I have a Context Menu Strip (contextColorOptions) that allows the ability to change the background color and forecolor of whatever sourcecontrol accessed the Context Menu Strip.
private void backgroundColorToolStripMenuItem_Click(object sender, EventArgs e)
{
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
contextColorOptions.SourceControl.BackColor = colorDialog1.Color;
}
}
private void textColorToolStripMenuItem_Click(object sender, EventArgs e)
{
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
contextColorOptions.SourceControl.ForeColor = colorDialog1.Color;
}
}
private void resetColorsToolStripMenuItem_Click(object sender, EventArgs e)
{
contextColorOptions.SourceControl.BackColor = DefaultBackColor;
contextColorOptions.SourceControl.ForeColor = DefaultForeColor;
}
I want to be able to assign every control in my form to have the same context menu strip.
I tried this:
foreach (Control cntrl in this.Controls)
{
cntrl.ContextMenuStrip = contextColorOptions;
}
But that didn't seem to work. does anyone have any ideas? Thank you in advance!