检查窗口的计数器变量是否打开 [英] Counter variable for check windows form open or not

查看:96
本文介绍了检查窗口的计数器变量是否打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要帮助检查并传递我打开的表格的计数器变量。



我有两种不同的形式。 studentform和teacherform

如果我打开学生表格填写条目并在datagridview中添加条目然后保存以插入条目。


现在
我是学生表格,然后点击教师主表格按钮去教师主表格。



然后



i需要计数器变量为我开放的老师大师,或者我如何获得信息我打开老师的主表格

谢谢。



我尝试了什么:



hello everyone,
i need help for check and pass counter variable for form which i open.

i have two different forms. studentform, and teacherform
if i open student form and fill entries and add entries in datagridview and then save to insert that entries.

now i am at student form and go to teacher master form by click on button for teacher master form.

then

i need counter variable for i open teacher master, or how can i get information i open the teacher master form
thank you.

What I have tried:

hello everyone,
i need help for check and pass counter variable for form which i open.

i have two different forms. studentform, and teacherform
if i open student form and fill entries and add entries in datagridview and then save to insert that entries.

now i am at student form and go to teacher master form by click on button for teacher master form.

then

i need counter variable for i open teacher master, or how can i get information i open the teacher master form
thank you.

推荐答案

最简单的解决方案是让表单本身处理它。

将表单创建为Singleton:构造函数变为 private 并添加静态GetInstance方法,该方法返回现有实例(如果可用)或创建并显示新实例(如果不可用)。

然后,Form类维护一个静态实例变量,该变量保存 null 或表单本身,并在Form Closed事件发生时清除它。在GetInstance方法中检查此变量以确定您是否还有要返回的实例。



有意义吗?
The simplest solution is to let the form itself handle it.
Create the form as a Singleton: the constructor becomes private and you add a static GetInstance method which returns the existing instance (if it's available) or creates and displays a new instance (if it isn't).
The Form class then maintains a static Instance variable which holds null or the form itself, and you clear it when the Form Closed event happens. This variable is checked in your GetInstance method to determine if you have an instance to return yet.

Make sense?


这篇关于检查窗口的计数器变量是否打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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