创建胜利的过程CMD。形成另一个类c#win。形成 [英] Create Process CMD of win. form in another class c# win. form

查看:66
本文介绍了创建胜利的过程CMD。形成另一个类c#win。形成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一下,我有一个名为 Form_Save 的窗体,我要创建ProcessCmdKey( ProcessCMDKeys的参考链接在另一个类中,但它应该从Form_Save中读取键并希望在Form_Save中将其用作方法或函数。这可能吗?如果是的话怎么样?



对不起,如果我不够清楚





提前致谢

I want to ask that i have a windows form named Form_Save of which i want to create ProcessCmdKey(Link for Refrence of ProcessCMDKeys) in another class but it should read keys from "Form_Save" and want to use it in "Form_Save" as a method or function. Is This possible? if yes how?

Sorry if i was not clear enough


Thanks in advance

推荐答案

在您的评论中,您说要执行此操作,以便您可以以其他形式重复使用该方法。在这种情况下,您可以创建一个处理ProcessCmdKey的表单,并使Form_Save(可能还有其他形式)派生自该表单:

In your comment, you said that you want to do this so you can re-use the method in other forms. In that case, you can make a form that handles ProcessCmdKey, and make Form_Save (and perhaps other forms) derive from that form:
class ProcessCmdKeysForm : Form
{
    protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
    {
        // ...
    }
}

class Form_Save : ProcessCmdKeysForm
{
    // ...
}

class AnotherFormIfYouWant : ProcessCmdKeysForm
{
    // ...
}

这篇关于创建胜利的过程CMD。形成另一个类c#win。形成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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