ControlDesigner
GetHitTest
https://stackoverflow.com/questions/7762397/how-do-i-click-a-usercontrols-child-in-designer
@Bradley: thanks for pointing me in the right direction
You will need to write a ControlDesigner class, then use it in a [Designer( ... )]
attribute on your UserControl.
See the example here: http://msdn.microsoft.com/en-us/library/sycctd1z(v=VS.90).aspx
For the actual click:
The ControlDesigner has a protected bool GetHitTest(Point point)
method - you can implement this in your ControlDesigner and return true
when you want your control to handle a click, based on the click's location on the screen.
Example
protected override bool GetHitTest(Point point)
{
bool flag = false;
ASVerticalTab tab = Control as ASVerticalTab;
if (tab != null)
{
Point clientPoint = tab.PointToClient(point); foreach (Control control in tab.TabPages)
{
ASVerticalTabPage tabPage = control as ASVerticalTabPage;
if (tabPage == null)
{
continue;
}
var menuItem = tabPage.MenuItem;
var actualRectangle = new Rectangle(menuItem.Location, menuItem.Size);
if (actualRectangle.Contains(clientPoint))
{
flag = true;
break;
}
}
}
return flag;
}
关于DesignMode
LicenseManager.UsageMode
is intended for this.
It is in fact the only reliable way to detect if your control is in design mode or not. It's only valid during the constructor, but it can easily be stored in a field of the class for later reference.
The DesignMode
property for nested controls will be false even when the container control is in design mode.
在类的构造函数里面,使用一个字段存一下 LicenseManager.UsageMode
相关资料
http://www.cnblogs.com/blueglass/archive/2012/06/01/2530030.html
ControlDesigner的更多相关文章
- 在ASP.NET MVC中使用CKEditor和CkFinder
在你需要使用editor控件的页面头部添加: <head> ... <script type="text/javascript" src="/ckedi ...
- ASP.NET自定义控件组件开发 第五章 模板控件开发
原文:ASP.NET自定义控件组件开发 第五章 模板控件开发 第五章 模板控件开发 系列文章链接: ASP.NET自定义控件组件开发 第一章 待续 ASP.NET自定义控件组件开发 第一章 第二篇 接 ...
- 将ASP.NET用户控件转化为自定义控件
将ASP.NET用户控件转化为自定义控件 作者:Kevin Cheng (程建和) 最后修改时间:2006-03-14 概述:如何将ASP.NET用户控件移植为ASP.NET自定义控件 关键字:Asp ...
- System.Windows.Forms.Control : Component, IOleControl, IOleObject, IOleInPlaceObject, IOleInPlaceActiveObject....
#region 程序集 System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ...
- KRBTabControl(中文)Windows选项卡控件
本文阐述了如何在C#使自定义Windows选项卡控件. Download demo project - 82.4 KB Download source - 252 KB 介绍 本文讨论如何使用.NET ...
- KRBTabControl
This article explains how to make a custom Windows Tab Control in C#. Download demo project - 82.4 K ...
- C#中的自定义控件中的属性、事件及一些相关特性的总结(转)
摘要: C#中的自定义控件中的属性(Property).事件(Event)及一些相关特性(Attribute)的总结 今天学习了下C#用户控件开发添加自定义属性的事件,主要参考了MSDN,总结并实 ...
- PropertyGrid—隐藏某些Public属性
1.定义一个继承ControlDesigner 的类 public class MyControlDesigner:System.Windows.Forms.Design.ControlDesigne ...
- (六十九)c#Winform自定义控件-垂直滚动条
前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...
随机推荐
- 关于.net core 在docker中监听地址设置踩坑记
1.今天在做docker容器的时候发现如果将.net core 内部监听地址设置为localhost:8888. 2.在docker build -p 6444:8888 运行容器后,外部通过6444 ...
- mysql5.7 安装方法 (跟旧的不一样了)
MySQL 5.7发布之后很多网友都在说,打开想安装文件夹.但是文件夹中没有DATA目录, 没有mysqly默认库.启动不了数据库,那是因为5.7的数据库的初始化方法和之前的初始化不一样了. 首先这里 ...
- 洛谷 P2744 [USACO5.3]量取牛奶Milk Measuring
P2744 [USACO5.3]量取牛奶Milk Measuring 题目描述 农夫约翰要量取 Q(1 <= Q <= 20,000)夸脱(夸脱,quarts,容积单位——译者注) 他的最 ...
- ffmpeg命令详解(转)
FFmpeg是一套可以用来记录.转换数字音频.视频,并能将其转化为流的开源计算机程序.采用LGPL或GPL许可证.它提供了录制.转换以及流化音视频的完整解决方案.它包含了非常先进的音频/视频编解码库l ...
- python 与cpp接口编程
(1)vc6下面生成dll学习 1.使用 VC6.0 生成 DLL新建项目 “Win32 Dynamic-Link Library”,输入项目名称,确定后选择 “A simple DLL projec ...
- 在独立的文件里定义WPF资源
一.文章概述 本演示介绍怎样在单独的文件里定义WPF资源.并在须要的地方调用相关资源文件. 相关下载(代码.屏幕录像):http://pan.baidu.com/s/1sjO7StB 在线播放:htt ...
- QTP11.5公布,改名UFT
QTP11.5公布,改名UFT,支持多脚本编辑调试.PDF检查点.持续集成系统.手机測试等 http://www.learnqtp.com/hp-uft11-5-qtp-new-features/ T ...
- linux系统调用表(system call table)
系统调用号 函数名 入口点 源码 0 read sys_read fs/read_write.c 1 write sys_write fs/read_write.c 2 open sys_open f ...
- BZOJ 3503 高斯消元
思路: 高斯消元就好啦 注意每个格子最多只能和4个相邻 所以是 n*m*n*m*5 的 并不会TLE //By SiriusRen #include <cstdio> #include & ...
- Everedit软件下载、安装和运行(免注册)
不多说,最近,无意中,留意到这款软件. 前言 1.这是免注册版本 (推荐,这个是别人开发做出来的,放心!) 2.这是需注册版本 (这个是去官网) EverEdit是专门为国人设计的一流文本 ...