获取表单名称的问题函数 [英] problem function that gets the name of the form

查看:76
本文介绍了获取表单名称的问题函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是我想要一个名为put的形式的函数,而不是如何

nesesito帮助



删除了代码块格式 - ProgramFox [/ Edit]





OP'的附加信息来自非下面的解决方案 - Nelek

我想创建一个函数,检测该表单已被称为函数。

的目的是制作一个消息框样式表单只有个性化而且不能复制相同形式的函数调用单个表单和这个形式sierre被称为



idk如果我解释得很好并且对不起不要轻易错过anes

My problem is that I want a function of the form that is called the put disabled that and not how
nesesito help

Code block formatting removed - ProgramFox[/Edit]


OP''s additional information moved from non-solution below - Nelek
I want to create a function that detects that form has been called the function.
the purpose is to make a message box style form that only personalized and to not be copying the same form that the function call to a single form and this form sierre which was called

idk if I explain well and sorry for not tap to miss anes

推荐答案

你的英语没有多大意义,但我会猜测你的意思。



如果您认为需要确定调用方法的表单名称,则存在严重的设计缺陷。



首先,做因此会将您的代码直接耦合到这些表单,从而无法在不破坏另一个表单的情况下修改它们,并且无法在其他应用程序或情境中使用该代码。例如,您正在编写此方法以查找调用它的表单类的名称,但是您突然想要从非Form类显示MessageBox的内容?现在你被卡住了......



其次,如果你的代码中的功能需要改变,根据调用它的形式,你是最好不要在每个表单的类中放置该方法代码。



现在,在您的代码中,您不会向用户显示表单的类名。如果MessageBox需要显示表单的名称,那么表单代码通常可以调用创建MessageBox的方法并将用户友好名称作为字符串传递。
Your English doesn''t make much sense, but I''ll take a guess at what you mean.

If you think you need to do determine the name of the form that called your method, you have a serious design flaw.

First, doing so would couple your code directly to those forms, making it impossible to modify one without breaking the other and making it impossible to use the code in other applications or situations. For example, you''re coding this method to find the name of the form class that called it, but what it you suddenly wanted to show the MessageBox from a non-Form class?? Now you''re stuck...

Second, if you have functionality in that code that needs to change, based on form that called it, you''re much better off putting that method code in the class for each form.

Now, in your code, you would not show the class name of the form to the user. If the MessageBox needs to show the name of a form, your form code could would normally call method that creates the MessageBox and pass in a user friendly name as a string.


这篇关于获取表单名称的问题函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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