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.

有帮助吗?

解决方案

assuming the click handler lives in the form:

this.TopMost = alwaysOnTopToolStripMenuItem.Checked;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top