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:

http://msdn.microsoft.com/en-us/library/system.windows.forms.design.controldesigner.gethittest(v=VS.90).aspx

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

https://stackoverflow.com/questions/4346361/winform-custom-control-designmode-doesnt-return-true-whereas-in-design-mode

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

Extending Design-Time Support

Custom Designers

ControlDesigner的更多相关文章

  1. 在ASP.NET MVC中使用CKEditor和CkFinder

    在你需要使用editor控件的页面头部添加: <head> ... <script type="text/javascript" src="/ckedi ...

  2. ASP.NET自定义控件组件开发 第五章 模板控件开发

    原文:ASP.NET自定义控件组件开发 第五章 模板控件开发 第五章 模板控件开发 系列文章链接: ASP.NET自定义控件组件开发 第一章 待续 ASP.NET自定义控件组件开发 第一章 第二篇 接 ...

  3. 将ASP.NET用户控件转化为自定义控件

    将ASP.NET用户控件转化为自定义控件 作者:Kevin Cheng (程建和) 最后修改时间:2006-03-14 概述:如何将ASP.NET用户控件移植为ASP.NET自定义控件 关键字:Asp ...

  4. System.Windows.Forms.Control : Component, IOleControl, IOleObject, IOleInPlaceObject, IOleInPlaceActiveObject....

    #region 程序集 System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ...

  5. KRBTabControl(中文)Windows选项卡控件

    本文阐述了如何在C#使自定义Windows选项卡控件. Download demo project - 82.4 KB Download source - 252 KB 介绍 本文讨论如何使用.NET ...

  6. KRBTabControl

    This article explains how to make a custom Windows Tab Control in C#. Download demo project - 82.4 K ...

  7. C#中的自定义控件中的属性、事件及一些相关特性的总结(转)

      摘要: C#中的自定义控件中的属性(Property).事件(Event)及一些相关特性(Attribute)的总结 今天学习了下C#用户控件开发添加自定义属性的事件,主要参考了MSDN,总结并实 ...

  8. PropertyGrid—隐藏某些Public属性

    1.定义一个继承ControlDesigner 的类 public class MyControlDesigner:System.Windows.Forms.Design.ControlDesigne ...

  9. (六十九)c#Winform自定义控件-垂直滚动条

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...

随机推荐

  1. POJ-1276 Cash Machine 多重背包 二进制优化

    题目链接:https://cn.vjudge.net/problem/POJ-1276 题意 懒得写了自己去看好了,困了赶紧写完这个回宿舍睡觉,明早还要考试. 思路 多重背包的二进制优化. 思路是将n ...

  2. js img图片加载失败,重新加载+断网检查

    我们常常会遇到img加载图片的时候因为网络问题或者图片过大导致图片加载失败的问题,页面就因为这张蹦掉的图变得不美观.所以我们需要图片加载失败的时候重新加载图片,前端图片加载优化 //js方法定义 fu ...

  3. ping,telnet,ssh命令的理解

    ping主要用于测试到达目的主机的网络是否连接,但是它不能检测某个端口是否开放. ping 域名可以直接看出这个域名对应的ip ssh与telnet都是远程登录工具. ssh对传输加密,安全性高,te ...

  4. 什么是面向对象以及其意义,prototpye原型

    什么是面向对象: 使用对象时,只关注对象提供的功能,不关注其内部的细节 例如:jquery 什么是对象: 对象是一个整体对外提供一些操作,比如 收音机 面向对象编程OOP的特点: 1.抽象:把主要的特 ...

  5. 洛谷 P2730 魔板 Magic Squares

    P2730 魔板 Magic Squares 题目背景 在成功地发明了魔方之后,鲁比克先生发明了它的二维版本,称作魔板.这是一张有8个大小相同的格子的魔板: 1 2 3 4 8 7 6 5 题目描述 ...

  6. OpenStack 与 大数据的融合

        此处是hadoop 2.7.2以前 Hadoop 预留的一个 HDFS 文件系统的接口. 可以通过修改这里 将数据源的读取改为 Swift. 也可以通过修改 MR 源码 将数据抽取部分变换成 ...

  7. Android中加入思源字体/NotoSansCJK/SourceHanSans

    系统版本号:Android 4.2.2_r1 本文主要是在Android中加入思源字体的过程记录. 思源字体是Google和Adobe在2014.07.18公布的中文字体. 1.获取思源字体(Goog ...

  8. Dubbo分布式服务框架入门(附project)

    要想了解Dubbo是什么,我们不防先了解它有什么用. 使用场景:比方我想开发一个网上商城项目.这个网上商城呢,比較复杂.分为pc端web管理后台.微信端销售公众号,那么我们分成四个项目,pc端站点,微 ...

  9. hibernate动态表名映射--仅仅有想不到,没有做不到

    近期的一个项目有一个需求,有N个考核单位,要对每一个考核单位生成一张考核情况表.这样做的目的是横切数据库,这这个需求的实现中,我的组员遇到了一个技术问题,我将我的解决的方法和整个思考过程与大家分享, ...

  10. hdu_1698线段树成段更新

    #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #d ...