从另一个表单更改表单TopMost [英] Change Form TopMost from another Form

查看:111
本文介绍了从另一个表单更改表单TopMost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

namespace Test {
    public partial class Form2 : Form {
        Form1 Me;

        public Form2(Form1 form1) {
            InitializeComponent();
            Me = form1;
        }

        public class General {
            [Category("Settings"), DisplayName("Stay on top")]
            public bool StayOnTop {
                get { return Me.TopMost; }
                set { Me.TopMost = value; }
            }
        }

        private void Form2_Load(object sender, EventArgs e) {
            General general = new General();
            propertyGrid1.SelectedObject = general;
        }
    }
}





错误1无法访问外部类型的非静态成员'test.Form2'通过嵌套类型'Test.Form2.General'



Error 1 Cannot access a non-static member of outer type 'Test.Form2' via nested type 'Test.Form2.General'

推荐答案

这是一个非常空洞的问题,基于不了解表单类和实例是只是类和实例,与任何其他类型和实例(对象)没有太大的不同,不了解一般编程。

请参阅我的文章我专门针对这样的情况编写:一次回答的许多问题 - Windows窗体或WPF Windows之间的协作 [ ^ ]。



-SA
This is a pretty much empty question, based on not understanding that form classes and instances are just classes and instances, not much different from any other types and instances (object), not understanding general programming.
Please see my article I wrote specially for such cases: Many Questions Answered at Once — Collaboration between Windows Forms or WPF Windows[^].

—SA


这篇关于从另一个表单更改表单TopMost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆