如何把一个扩展的WinForms控制上的工具箱 [英] How to put an extended WinForms Control on ToolBox

查看:144
本文介绍了如何把一个扩展的WinForms控制上的工具箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我计划的功能添加到文本框的以下内容:

 公共类TextBoxExt:文本框
{
保护覆盖无效的OnKeyPress(KeyPressEventArgs E)
{
base.OnKeyPress(E);
}

}



现在的问题是我们如何使用这TextBoxExt?反正是有得到这个类到工具箱,使我们可以只需拖放到窗体?如果没有,什么是使用TextBoxExt最好的方法是什么?


解决方案

  1. 构建你TextBoxExt项目,确保它编译ok了。

  2. 与您要在TextBoxExt的形式,打开工具箱,点击右键,选择选择项

  3. 浏览到您.exe或您在1编译DLL)

  4. 确保该TextBoxExt旁边有一个勾号,按OK

  5. TextBoxExt应出现在工具箱中,将其拖动到窗体



(没有这样做,打开设计文件和重命名实例的另一种方式文本框TextBoxExt但设计师文件手工编辑可以被某些人认为是危险的)


I plan to add functionalities to TextBox with the following:

   public class TextBoxExt : TextBox  
    {
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            base.OnKeyPress(e);
        }

    }

The question is how can we use this TextBoxExt? Is there anyway to get this class onto the ToolBox so that we can just drag and drop it onto the form? If not, what is the best way to use the TextBoxExt?

解决方案

  1. Build you project with TextBoxExt, make sure it compiles ok.
  2. With the form that you want TextBoxExt on, open the toolbox, right click and select "choose items"
  3. Browse to you .exe or dll that you compiled in 1)
  4. make sure that TextBoxExt has a tick next to it, press ok
  5. TextBoxExt should appear in the toolbox, drag it onto your form

(There is another way of doing this, opening the designer file and renaming the instances of TextBox to TextBoxExt but manual editing of designer files can be considered hazardous by some)

这篇关于如何把一个扩展的WinForms控制上的工具箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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