试图动态显示用户控件,如何实现? [英] Attemping dynamic displaying a usercontrol,how to implement this?

查看:81
本文介绍了试图动态显示用户控件,如何实现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想利用自定义控件(ui就像一个按钮)在用户点击它时动态显示一棵树。当自定义控件失去焦点时隐藏树。

如何获得它? />
(此外不能使用Form控件。)

I want utilize a custom control(ui like a button) dynamic show a tree under it when user click it.And hide tree when custom control lost focus.
how to get it ?
(In addition can''t use Form control.)

推荐答案

这就像

This is something like
class MyControl : System.Windows.Forms.Control { // or some other base class

   protected override void OnGotFocus(System.EventArgs eventArgs) {
      this.TreeView.Visuble = true;
      // ...
   }

   protected override void OnLostFocus(System.EventArgs eventArgs) {
      this.TreeView.Visuble = false;
      // ...
   }

   // ...

   System.Windows.Forms.TreeView TreeView = new System.Windows.Forms.TreeView();

}



请参阅:

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.ongotfocus.aspx [ ^ ],

http:// msdn .microsoft.com / zh-cn / library / system.windows.forms.control.onlostfocus.aspx [ ^ ]。



简单,不是''是吗?



-SA


这篇关于试图动态显示用户控件,如何实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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