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. ...
随机推荐
- OpenJudge计算概论-短信计费
/*===================================== 短信计费 总时间限制: 1000ms 内存限制: 65536kB 描述 用手机发短信,一般一条短信资费为0.1元,但限定 ...
- 【转】第6篇:Xilium CefGlue 关于 CLR Object 与 JS 交互类库封装报告:自动注册JS脚本+自动反射方法分析
作者: 牛A与牛C之间 时间: 2013-11-21 分类: 技术文章 | 暂无评论 | 编辑文章 主页 » 技术文章 » 第6篇:Xilium CefGlue 关于 CLR Object 与 JS ...
- JQuery Pagenation 知识点整理——phototype 应用(20150517)(转)
JS中的phototype是JS中比较难理解的一个部分 本文基于下面几个知识点: 1 原型法设计模式 在.Net中可以使用clone()来实现原型法 原型法的主要思想是,现在有1个类A,我想要创建一个 ...
- 用java给html文件添加必要的控制html代码片
这个需求,我估计很多时候都不会用到,但是,我们目前在做一个CMS的系统,在创建页面的时候,需要控制页面各个板块显示的内容来源,这个不是关键,关键是页面内容配置完毕后,如何提交内容,也就是说如何和后台系 ...
- 调用Newtonsoft.Json 报FileNotFoundException 错误
具体如下: Exception StackTrace at Newtonsoft.Json.Converters.BinaryConverter.CanConvert(Type objectType) ...
- android学习笔记47——读写SD卡上的文件
读写SD卡上的文件 通过Context的openFileInput.openFileOutput来打开文件输入流.输出流时,程序打开的都是应用程序的数据文件夹里的文件,其存储的文件大小可能都比较有限- ...
- Linux中文件描述符fd和文件指针flip的理解
转自:http://www.cnblogs.com/Jezze/archive/2011/12/23/2299861.html 简单归纳:fd只是一个整数,在open时产生.起到一个索引的作用,进程通 ...
- RDA 编译器的搭建
apt-get install subversion apt-get install make atp-get install gcc sudo vim /etc/profile export PAT ...
- 64. Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which ...
- 黄聪:wordpress在IIS8中设置默认编码(windows2012服务器)
web.config中配置 <?xml version="1.0" encoding="UTF-8"?> <configuration> ...