Prevent Adding Component More than once
Question: I'm developing a C# component, I want to prevent the user from adding this component to the Form if the Form already has an instance of the component.
[Designer(typeof(myComponentDesigner))]
class myComponent : Component
{
public myComponent(IContainer container)
{
// Add object to container's list so that
// we get notified when the container goes away
container.Add(this);
}
} class myComponentDesigner : ComponentDesigner
{
public override void InitializeNewComponent(System.Collections.IDictionary defaultValues)
{
IDesignerHost service = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
if (service == null) return;
ComponentCollection cc = service.Container.Components; int count = ;
foreach (Component c in cc)
{
if (c.GetType() == this.Component.GetType() )
{
count++;
if (count > )
{
service.Container.Remove(this.Component);
MessageBox.Show(
"You cannot add more than one instance of the myComponet!");
return;
}
}
} base.InitializeNewComponent(defaultValues);
}
}
Prevent Adding Component More than once的更多相关文章
- Blazor组件自做五 : 使用JS隔离封装Google地图
Blazor组件自做五: 使用JS隔离封装Google地图 运行截图 演示地址 正式开始 1. 谷歌地图API 谷歌开发文档 开始学习 Maps JavaScript API 的最简单方法是查看一个简 ...
- GroupLayout 布局
文档说明: 以下引自:Java™ PlatformStandard Ed. 7 public class GroupLayout extends Object implements LayoutMan ...
- [SinGuLaRiTy] COCI 2011~2012 #2
[SinGuLaRiTy-1008] Copyright (c) SinGuLaRiTy 2017. All Rights Reserved. 测试题目 对于所有的题目:Time Limit:1s ...
- gitlab通过api创建组、项目、成员
前戏 获取gitlab中admin用户的private_token Groups API 获取某个组的详细 curl --header "PRIVATE-TOKEN: *********&q ...
- 基于vue实现上下滑动翻页效果
18年年底的时候,一直在做年度报告的H5页面,因为项目需要,需要实现上下滑动翻页,并且上滑的页面比正常页面的比例要缩小一定比例. 效果类似于http://www.17sucai.com/pins/de ...
- Vickers Vane Pump - Hydraulic Vane Pump Failure: Cavitation, Mechanical Damage
One of our readers recently wrote to me about the following questions: “Recently, we purchased a sec ...
- hexo next主题深度优化(一),加入pjax功能。
文章目录 背景: 进入正题 pjax初体验--instantclick 真正的pjax 第一步 第二步 第三步 第四步 专门基于hexo next主题的pjax(将丢失的js效果重现) 将下面讲到的提 ...
- Blazor组件自做八 : 使用JS隔离封装屏幕键盘kioskboard.js组件
1. 运行截图 演示地址 2. 在文件夹wwwroot/lib,添加kioskboard子文件夹,添加kioskboards.js文件 2.1 常规操作,懒加载js库, export function ...
- [Angular] Adding keyboard events to our control value accessor component
One of the most important thing when building custom form component is adding accessbility support. ...
随机推荐
- Jquery使用ajax以及angularjs 动态模板加载并进行渲染
1. 源码 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <tit ...
- java从零到变身爬虫大神(一)
学习java3天有余,知道一些基本语法后 学习java爬虫,1天后开始出现明显效果 刚开始先从最简单的爬虫逻辑入手 爬虫最简单的解析面真的是这样 import org.jsoup.Jsoup; imp ...
- 查询oracle RAC实例名称等信息
select * from gv$instance;
- ASP.NET MVC几种找不到资源的问题解决办法
转自:http://www.cnblogs.com/xyang/archive/2011/11/24/2262003.html 在MVC中,controller中的Action和View中的.csht ...
- 用php自带的filter函数验证、过滤数据 -转载
PHP过滤器包含两种类型 Validation:用来验证验证项是否合法 Sanitization:用来格式化被验证的项目,因此它可能会修改验证项的值,将不合法的字符删除等. input_filters ...
- window.location.search
http://i.cnblogs.com/EditPosts.aspx?opt=1&opt2=x 就拿上面这个URL来说window.location.search的返回值为opt=1& ...
- winserver 2008 r2 iis7.5 实现php wordpress url静态化操作步骤(UrlRewrite实现)
参考网址:http://jingyan.baidu.com/article/cbf0e500ebec582eaa2893d2.html 文中涉及到的程序源码以及配置 详见附件:http://files ...
- android 模拟抢红包 原理
Android微信抢红包外挂 源代码 标签: 微信 抢红包 外挂 插件 2015-02-20 22:59 30211人阅读 评论(16) 收藏 举报 分类: Android(58) 版权声明:本文 ...
- linux下进程、端口号相互查看方法
linux下通过进程名查看其占用端口: 1.先查看进程pid ps -ef | grep 进程名 2.通过pid查看占用端口 netstat -nap | grep 进程pid 例:通过nginx进程 ...
- SVN并行开发管理策略
总的原则:trunk保证相对稳定.分支合并到主干时将冲突降至最低. (1) trunk用于集成.测试.发布,可以提交fixbug代码,但不允许直接提交新特性. (2) 特性在分 ...