Question

I need create one item in my ToolStripMenuItem with this feature: if I check it, in application is turn on "stay on top" property.

I tryed this code:

private void alwaysOnTopToolStripMenuItem_CheckedChanged(object sender, EventArgs e)
    {
        if (alwaysOnTopToolStripMenuItem.Checked)
            fForm1.TopMost = true;
        else
        {
            fForm1.TopMost = false;
        }
    }

but I get this error in Visual Studio 2010 (Windows Form)

enter image description here

I dont know how I can solve this strage issue. Thanks in advance.

Était-ce utile?

La solution

assuming the click handler lives in the form:

this.TopMost = alwaysOnTopToolStripMenuItem.Checked;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top