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. -bash: nginx: 未找到命令 (command not found) 解决方案

    昨天在linux中安装了 nginx ,并按照网上教程 进行启动 如: ps -ef | grep nginx 可以查看到 我就想重新加载一次 如:提示我找不到 nginx 命令 -c参数指定了要加载 ...

  2. 学习参考《Flask Web开发:基于Python的Web应用开发实战(第2版)》中文PDF+源代码

    在学习python Web开发时,我们会选择使用Django.flask等框架. 在学习flask时,推荐学习看看<Flask Web开发:基于Python的Web应用开发实战(第2版)> ...

  3. 如何绑定host

    绑定host一般分为windows和linux下两种情况. windows下,首先打开host文件,其操作步骤 ,打开 C:\Windows\System32\Drivers\etc\hosts的文件 ...

  4. php7 memcache和memcached.so扩展

    php7安装memcache和memcached扩展 https://github.com/websupport-sk/pecl-memcache https://github.com/php-mem ...

  5. 【codeforces 128C】Games with Rectangle

    [题目链接]:http://codeforces.com/problemset/problem/128/C [题意] 让你一层一层地在n*m的网格上画k个递进关系的长方形;(要求一个矩形是包含在另外一 ...

  6. Eclipse集成Git插件及使用

    目录(?)[+] 1 Git插件安装 11 下载插件 2 Git提交代码 21 建git的本地仓库 第一种 第二种 项目创建本地仓库后 如图 22 提交本地仓库 23 提交远程仓库 3 Git下载代码 ...

  7. 重写MPAndroidChart显示标记

    MPAndroidChart是实现图表功能的优秀控件, 能够完毕大多数绘制需求. 对于改动第三方库而言, 优秀的架构是继承开发, 而不是把源代码拆分出去. MP在显示标记控件(MarkView)时, ...

  8. 设置和获取Android中各种音量

    通过程序获取android系统手机的铃声和音量.同样,设置铃声和音量的方法也很简单! AudioManager am = (AudioManager) getSystemService(Context ...

  9. MyBatis、JDBC、Hibernate区别

    从层次上看,JDBC是较底层的持久层操作方式,而Hibernate和MyBatis都是在JDBC的基础上进行了封装使其更加方便程序员对持久层的操作. 从功能上看, JDBC就是简单的建立数据库连接,然 ...

  10. TabLayout禁止选择

    项目中有个页面上面是TabLayout下面是Listview,选择TabLayout的选项卡更新下面Listview里面的数据,在请求的时候想禁用TabLayout选项卡来避免用户频繁点击选项卡造成L ...