检查窗口的计数器变量是否打开

编程入门 行业动态 更新时间:2024-10-22 08:44:32
本文介绍了检查窗口的计数器变量是否打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我需要帮助检查并传递我打开的表格的计数器变量。 我有两种不同的形式。 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?

更多推荐

检查窗口的计数器变量是否打开

本文发布于:2023-11-22 06:47:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616379.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   计数器   窗口

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!