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 ...
随机推荐
- mysql忘记密码怎么处理
1修改/etc/my.cnf文件 在[mysqld]下加一行skip-grant-tables 2.重启mysql使配置生效 3.免密码登录mysql并设置新密码 设置新的root密码,并刷新权限 4 ...
- Python学习————集合的增删查
可变的数据类型,他里面的元素必须是不可变的数据类型.无序,内容不能重复.应用于去重 增加:set1.add('元素')--->将元素无序的插入集合set1中set1.update("元 ...
- mysql索引的使用及优化方法
数据库高级管理及优化 MySQL性能优化 优化MySQL数据库是数据库管理员和数据库开发人员的必备技能.优化MySQL,一方面是找出系统的瓶颈,提高MySQL数据库整体的性能:另一方面是合理设计结构和 ...
- Apache activemq入门示例(maven项目)
http://outofmemory.cn/java/mq/apache-activemq-demo
- HDU——T 1068 Girls and Boys
http://acm.hdu.edu.cn/showproblem.php?pid=1068 Time Limit: 20000/10000 MS (Java/Others) Memory Li ...
- Android基础笔记(十三)- 内容提供者原理和简单使用
为什么要有内容提供者 内容提供者的工作原理 使用内容解析者对内容提供者进行增删改查操作 利用内容提供者和内容解析者备份手机短信 利用内容提供者插入短信 为什么要有内容提供者 内容提供者技术的目的是: ...
- ios的notification机制是同步的还是异步的
与javascript中的事件机制不同.ios里的事件广播机制是同步的,默认情况下.广播一个通知,会堵塞后面的代码: -(void) clicked { NSNotificationCenter *c ...
- swift学习笔记(五)构造过程
构造过程是为了使用某个类.结构体或枚举类型的实例而进行的准备过程.在构造过程中,对每一个属性进行了初始值预设和其它必要的准备和初始化工作. 与OC相比,swift的构造函数.不须要返回值.同一时候,在 ...
- mysql-汇总(聚集)函数
我们需要汇总数据而不用把他们实际检索出来,他们主要用来进行分析和报表数据的生成. 1.AVG:通过对表中行数计数并计算特定列值之和,求得该列的平均值.可用来返回所有列的平均值,也可以用来返回特定列或行 ...
- 集群环境下,Session管理的几种手段
集群环境下,Session管理的几种手段 1.Session复制 缺点:集群服务器间需要大量的通信进行Session复制,占用服务器和网络的大量资源. 由于所有用户的Session信息在每台服务器上都 ...