最新文章 (全部类别)
C# 使用Linq递归查询当前节点及所有子节点
You must install .NET Desktop Runtime to run this application
Swagger生成API接口注释、参数注释、实体模型注释
Failed to load APl definition. response status is 500 /swagger/vl/swagger.json
.NET8/.NETCore 依赖接口注入:自动注入项目中所有接口和自定义类
CSFramework.EF应用 - ASP.NETCore/WebApi使用IDatabase动态代理创建多个数据库实例
CSFramework.EF数据库框架简介
EFCore查询数据报错:SqlNullValueException:“Data is Null. This method or property cannot be called on Null values
使用Photoshop PS制作GIF动画(等待窗体GIF图标)
C# Winform等待窗体WaitingForm组件下载(CSFramework提供)
使用VS2022升级助手将.NETFramework项目升级到.NET8/.NETCore
VS解决方案升级:.NETFramework升级到.NETCore(.NET6~.NET8)
CSFramework.COM C/S软件开发框架视频下载
CSFramework.Authentication 软件证书管理系统 - MAC地址管理
CSFramework.Authentication 软件证书管理系统 - 证书管理
CSFramework.Authentication 软件证书管理系统 - 制作软件授权证书
CSFrameworkV6快速开发框架 - SqlServer(MsSql)数据库测试报告
C/S架构软件开发平台 - 旗舰版V6 软件简介
C/S架构软件开发平台 - 旗舰版V6.1 - 新功能汇总
C/S客户端软件授权设计方案 - MAC地址白名单+软件到期时间授权
C/S客户端软件授权设计方案 - 在线用户并发数+软件到期时间授权
CSFramework.Authentication 软件授权证书管理系统
CSFrameworkV6旗舰版开发框架 - 集成软件授权认证系统
CSFrameworkV6旗舰版-新功能-在线用户查询、设置用户下线
CSFramework.Authentication 软件授权认证系统 - 软件测试报告
CSFrameworkV6旗舰版新功能-客户端软件授权(在线用户并发数+MAC白名单+软件到期时间)
特殊文本符号大全|Word中的特殊文本符号|图案符号
LINQ高级语法:使用ExecuteUpdate方法查询并批量更新数据(Where+Update)
C/S架构软件开发平台 - 旗舰版V6.0 - 底层框架迭代开发
DevExpress v24破解步骤
C#获取应用程序当前文件目录位置(安装路径)
SqlException: 列名 'Discriminator' 无效。
.NET C/S架构软件用户授权设计方案(mac地址+白名单用户)
B/S开发框架NuGet包、组件介绍
C/S框架软件产品客户案例
C/S架构软件开发平台 - 旗舰版V6.0 - 自动创建数据库备份计划
SqlServer自动备份计划,备份多个数据库,自动删除备份文件
CSFrameworkV6快速开发框架 - 两种报表数据源查询方式及优缺点
SqlServer使用xp_cmdshell删除备份文件
SqlServer备份数据库存储过程:p_BackupDB
IWebHostEnvironment接口怎么引用?
Docker Desktop使用指南(Windows操作系统)
VSCode开发工具使用笔记
本地源“C:\Program Files\DevExpress 22.2\Components\System\Components\Packages”不存在
CSFrameworkV6旗舰版-成功案例-合肥联宝MES系统
CSFrameworkV6旗舰版-成功案例-威海广泰MES系统
CSFrameworkV6软件开发框架+达梦数据库(国产数据库)测试报告
国产化软件设计:遵循信创要求,助力信息技术自主创新
DevExpress组件版本下载、安装与VS开发环境 - Winform C/S框架
CSFrameworkV6软件开发框架 - MySql数据库测试报告
.net敏捷开发,创造卓越

C#.Net组件开发(高级篇) - 开发复杂的设计时组件编辑器


  C#.Net组件开发(高级篇) - 开发复杂的设计时组件编辑器C#.Net组件开发(高级篇) - 开发复杂的设计时组件编辑器



积累了开发组件的基本知识,现在分享一个复杂的设计时组件编辑器,如下图:


贴图图片

该组件编辑器用于设计CSFrameworkComponent.InnerObject对象的内容。

贴图图片

InnerObject对象定义了两个字符类型的属性(ObjectCreator,ObjectName)和一个MyNodeCollection集合类型。

在窗体上拖放一个CSFrameworkComponent组件,点右键选择“编辑MyInnerObject对象”菜单。


贴图图片


InnerObject对象定义:



C# Code:

/// <summary>
/// 对象类型
/// </summary>
public class InnerObject
{
   public InnerObject()
   {
      _ObjectName = "对象名:" DateTime.Now.Ticks.ToString();
      _ObjectCreator = "Jonny Sun - C/S框架网";
      _MyNodeCollection = new MyNodeCollection();
   }
   
   private string _ObjectName = "";
   
   public string ObjectName
   {
      get { return _ObjectName; }
      set { _ObjectName = value; }
   }
   
   private string _ObjectCreator = "";
   
   public string ObjectCreator
   {
      get { return _ObjectCreator; }
      set { _ObjectCreator = value; }
   }
   
   private MyNodeCollection _MyNodeCollection;
   
   [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
   [Editor(typeof(MyCollectionEditor), typeof(UITypeEditor))]//属性编辑器
   public MyNodeCollection MyNodeCollection
   {
      get
      {
         return _MyNodeCollection;
      }
      set
      {
         _MyNodeCollection = value;
      }
   }
   
   public override string ToString()
   {
      //在属性编辑器内显示的名称
      return "(我的自定义对象)";
   }
}

//来源:C/S框架网(www.csframework.com) QQ:1980854898



CSFrameworkComponent 组件:




  /// <summary>

    /// 用户自定义组件

    /// </summary>

    [ToolboxBitmap(typeof(CSFrameworkComponent), "CSFrameworkComponent.bmp")]

    [DesignTimeVisible(true)]

    [Designer(typeof(CSFrameworkComponentDesigner), typeof(IDesigner))]

    public partial class CSFrameworkComponent : Component

    {

        //对象集合

        private MyNodeCollection _MyNodeCollection;

 

        //嵌套的对象

        private InnerObject _MyInnerObject;

 

        //窗体设计器的接口引用,当拖拉组件到窗体上,值由构造器传入.

        private IContainer _Designer;

 

        public CSFrameworkComponent(IContainer container)

            : base()

        {

            if (container == null) throw new Exception("必须指定组件的容器!");

 

            container.Add(this);

 

            _Designer = container;//窗体的引用

 

            //实例化自定义组件

            _MyNodeCollection = new MyNodeCollection();

            _MyInnerObject = new InnerObject();

        }

 

        /// <summary>

        /// 移除窗体设计器内的代码

        /// </summary>

        /// <param name="disposing"></param>

        protected override void Dispose(bool disposing)

        {

            //设计环境下销毁对象(移除Designer.cs内的代码)

            if ((this.DesignMode) || (_Designer is IDesignerHost))

            {

                IDesignerHost host = (IDesignerHost)_Designer;

 

                //从窗体设计器删除当前组件嵌套的组件代码

                foreach (IComponent c in _MyNodeCollection)

                    host.Container.Remove(c); //销毁组件(删除Designer.cs内的代码)

 

                //从窗体设计器删除当前组件嵌套的组件代码

                foreach (IComponent c in _MyInnerObject.MyNodeCollection)

                    host.Container.Remove(c); //销毁组件(删除Designer.cs内的代码)

            }

 

            base.Dispose(disposing);

        }

 

        /// <summary>

        /// 用于测试打开Collection Editor的编辑器窗体

        /// </summary>

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]

        [Editor(typeof(MyCollectionEditor), typeof(UITypeEditor))]//属性编辑器

        public MyNodeCollection MyNodeCollection

        {

            get

            {

                return _MyNodeCollection;

            }

            set

            {

                _MyNodeCollection = value;

            }

        }

 

        /// <summary>

        /// 用于测试打开自定义属性编辑器窗体

        /// </summary>

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]

        [Editor(typeof(MyInnerObjectEditor), typeof(UITypeEditor))]//属性编辑器

        public InnerObject MyInnerObject

        {

            get

            {

                return _MyInnerObject;

            }

            set

            {

                _MyInnerObject = value;

            }

        }

    }





生成的代码Form1.Designer.cs:


C# Code:

partial class Form1
{
   /// <summary>
   /// Required designer variable.
   /// </summary>
   private System.ComponentModel.IContainer components = null;
   
   /// <summary>
   /// Clean up any resources being used.
   /// </summary>
   /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
   protected override void Dispose(bool disposing)
   {
      if (disposing && (components != null))
      {
         components.Dispose();
      }
      base.Dispose(disposing);
   }
   
   #region Windows Form Designer generated code
   
   /// <summary>
   /// Required method for Designer support - do not modify
   /// the contents of this method with the code editor.
   /// </summary>
   private void InitializeComponent()
   {
      this.components = new System.ComponentModel.Container();
      this.button1 = new System.Windows.Forms.Button();
      this.csFrameworkComponent1 = new CSFramework.MyDesignEditor.CSFrameworkComponent(this.components);
      this.csFrameworkNode2 = new CSFramework.MyDesignEditor.CSFrameworkNode();
      this.csFrameworkNode3 = new CSFramework.MyDesignEditor.CSFrameworkNode();
      this.csFrameworkNode5 = new CSFramework.MyDesignEditor.CSFrameworkNode();
      this.csFrameworkNode6 = new CSFramework.MyDesignEditor.CSFrameworkNode();
      this.csFrameworkNode7 = new CSFramework.MyDesignEditor.CSFrameworkNode();
      this.csFrameworkNode8 = new CSFramework.MyDesignEditor.CSFrameworkNode();
      this.csFrameworkNode9 = new CSFramework.MyDesignEditor.CSFrameworkNode();
      this.csFrameworkNode10 = new CSFramework.MyDesignEditor.CSFrameworkNode();
      this.csFrameworkNode11 = new CSFramework.MyDesignEditor.CSFrameworkNode();
      this.csFrameworkNode12 = new CSFramework.MyDesignEditor.CSFrameworkNode();
      this.csFrameworkNode1 = new CSFramework.MyDesignEditor.CSFrameworkNode();
      this.csFrameworkNode4 = new CSFramework.MyDesignEditor.CSFrameworkNode();
      this.csFrameworkNode13 = new CSFramework.MyDesignEditor.CSFrameworkNode();
      this.csFrameworkNode14 = new CSFramework.MyDesignEditor.CSFrameworkNode();
      this.csFrameworkNode15 = new CSFramework.MyDesignEditor.CSFrameworkNode();
      this.csFrameworkNode16 = new CSFramework.MyDesignEditor.CSFrameworkNode();
      this.SuspendLayout();
      //
      // button1
      //
      this.button1.Location = new System.Drawing.Point(50, 50);
      this.button1.Name = "button1";
      this.button1.Size = new System.Drawing.Size(150, 30);
      this.button1.TabIndex = 0;
      this.button1.Text = "www.CSFramework.com";
      //
      // csFrameworkComponent1
      //
      this.csFrameworkComponent1.MyInnerObject.MyNodeCollection.Add(this.csFrameworkNode2);
      this.csFrameworkComponent1.MyInnerObject.MyNodeCollection.Add(this.csFrameworkNode3);
      this.csFrameworkComponent1.MyInnerObject.MyNodeCollection.Add(this.csFrameworkNode5);
      this.csFrameworkComponent1.MyInnerObject.MyNodeCollection.Add(this.csFrameworkNode6);
      this.csFrameworkComponent1.MyInnerObject.MyNodeCollection.Add(this.csFrameworkNode7);
      this.csFrameworkComponent1.MyInnerObject.MyNodeCollection.Add(this.csFrameworkNode8);
      this.csFrameworkComponent1.MyInnerObject.MyNodeCollection.Add(this.csFrameworkNode9);
      this.csFrameworkComponent1.MyInnerObject.MyNodeCollection.Add(this.csFrameworkNode10);
      this.csFrameworkComponent1.MyInnerObject.MyNodeCollection.Add(this.csFrameworkNode11);
      this.csFrameworkComponent1.MyInnerObject.MyNodeCollection.Add(this.csFrameworkNode12);
      this.csFrameworkComponent1.MyInnerObject.ObjectCreator = "Jonny Sun - C/S框架网555";
      this.csFrameworkComponent1.MyInnerObject.ObjectName = "对象名:634500426876739555555";
      this.csFrameworkComponent1.MyNodeCollection.Add(this.csFrameworkNode1);
      this.csFrameworkComponent1.MyNodeCollection.Add(this.csFrameworkNode4);
      this.csFrameworkComponent1.MyNodeCollection.Add(this.csFrameworkNode13);
      this.csFrameworkComponent1.MyNodeCollection.Add(this.csFrameworkNode14);
      this.csFrameworkComponent1.MyNodeCollection.Add(this.csFrameworkNode15);
      this.csFrameworkComponent1.MyNodeCollection.Add(this.csFrameworkNode16);
      //
      // csFrameworkNode2
      //
      this.csFrameworkNode2.ID = 1;
      this.csFrameworkNode2.NodeName = "名称:1";
      //
      // csFrameworkNode3
      //
      this.csFrameworkNode3.ID = 2;
      this.csFrameworkNode3.NodeName = "名称:2";
      //
      // csFrameworkNode5
      //
      this.csFrameworkNode5.ID = 3;
      this.csFrameworkNode5.NodeName = "名称:3";
      //
      // csFrameworkNode6
      //
      this.csFrameworkNode6.ID = 4;
      this.csFrameworkNode6.NodeName = "名称:4";
      //
      // csFrameworkNode7
      //
      this.csFrameworkNode7.ID = 5;
      this.csFrameworkNode7.NodeName = "名称:5";
      //
      // csFrameworkNode8
      //
      this.csFrameworkNode8.ID = 6;
      this.csFrameworkNode8.NodeName = "名称:6";
      //
      // csFrameworkNode9
      //
      this.csFrameworkNode9.ID = 7;
      this.csFrameworkNode9.NodeName = "名称:7";
      //
      // csFrameworkNode10
      //
      this.csFrameworkNode10.ID = 8;
      this.csFrameworkNode10.NodeName = "名称:8";
      //
      // csFrameworkNode11
      //
      this.csFrameworkNode11.ID = 9;
      this.csFrameworkNode11.NodeName = "名称:9";
      //
      // csFrameworkNode12
      //
      this.csFrameworkNode12.ID = 10;
      this.csFrameworkNode12.NodeName = "名称:10";
      //
      // csFrameworkNode1
      //
      this.csFrameworkNode1.ID = 470;
      this.csFrameworkNode1.NodeName = "www.CSFramework.com";
      //
      // csFrameworkNode4
      //
      this.csFrameworkNode4.ID = 307;
      this.csFrameworkNode4.NodeName = "www.CSFramework.com";
      //
      // csFrameworkNode13
      //
      this.csFrameworkNode13.ID = 0;
      this.csFrameworkNode13.NodeName = null;
      //
      // csFrameworkNode14
      //
      this.csFrameworkNode14.ID = 0;
      this.csFrameworkNode14.NodeName = null;
      //
      // csFrameworkNode15
      //
      this.csFrameworkNode15.ID = 0;
      this.csFrameworkNode15.NodeName = null;
      //
      // csFrameworkNode16
      //
      this.csFrameworkNode16.ID = 0;
      this.csFrameworkNode16.NodeName = null;
      //
      // Form1
      //
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.ClientSize = new System.Drawing.Size(734, 381);
      this.Controls.Add(this.button1);
      this.Name = "Form1";
      this.Text = "Form1";
      this.ResumeLayout(false);
      
   }
   
   #endregion
   
   private CSFrameworkComponent csFrameworkComponent1;
   private CSFrameworkNode csFrameworkNode2;
   private CSFrameworkNode csFrameworkNode3;
   private CSFrameworkNode csFrameworkNode1;
   private CSFrameworkNode csFrameworkNode4;
   private System.Windows.Forms.Button button1;
   private CSFrameworkNode csFrameworkNode5;
   private CSFrameworkNode csFrameworkNode6;
   private CSFrameworkNode csFrameworkNode7;
   private CSFrameworkNode csFrameworkNode8;
   private CSFrameworkNode csFrameworkNode9;
   private CSFrameworkNode csFrameworkNode10;
   private CSFrameworkNode csFrameworkNode11;
   private CSFrameworkNode csFrameworkNode12;
   private CSFrameworkNode csFrameworkNode13;
   private CSFrameworkNode csFrameworkNode14;
   private CSFrameworkNode csFrameworkNode15;
   private CSFrameworkNode csFrameworkNode16;
   
}

//来源:C/S框架网(www.csframework.com) QQ:1980854898





C/S框架网|原创精神.创造价值.打造精品


扫一扫加作者微信
C/S框架网作者微信 C/S框架网|原创作品.质量保障.竭诚为您服务


版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
C/S框架网
上一篇:Object Collection Editor窗体的Add/Delete按钮不可用
下一篇:C#.Net组件开发(高级篇) - 全部源码下载
评论列表

发表评论

评论内容
昵称:
关联文章

C#.Net开发(高级) - 开发复杂设计组件编辑器
C#.Net开发(高级) - 设计在窗体设计器文件内生成组件代码
C#.Net开发(高级) - 自定义CollectionEditor编辑器
C#.Net开发(高级) - 使用自定义TypeConverter生成设计代码
C#.Net开发 - 设计使用自定义属性编辑器持久化对象
C#.Net开发(高级) - 全部源码下载
标签:C#.Net开发 - 自定义属性编辑器持久化对象属性
C# DevExpress高级 - GridLookUpEdit使用
标签:C#.Net开发 - 设计持久化对象数组
标签:C#.Net开发 - 自定义设计器持久化对象属性
标签:C#.Net开发 - 自定义设计器(ComponentDesigner)
C#.Net开发继承UITypeEditor接口自定义属性编辑器
SQL注入漏洞全接触--高级
C#.Net开发 - 使用Attach to Process实时调试设计器代码
标签:C#.Net开发 - 属性窗体内显示自定义名称
组件区别(Control&Component区别)
C#.Net 调用Delphi 编译ActiveX COM(原)
Dev表格RepositoryItemLookUpEdit改变值设置其它列值-原创
C# DevExpress教学 GridLookUpEdit表格下拉组件使用
DevExpress皮肤组件打造C# Winform 开发平台

热门标签
软件著作权登记证书 .NET Reactor .NET5 .NET6 .NET7 .NET8 .NETFramework APP AspNetCore Auth-软件授权注册系统 Axios B/S B/S开发框架 B/S框架 BSFramework Bug Bug记录 C#加密解密 C#源码 C/S CHATGPT CMS系统 CodeGenerator CSFramework.DB CSFramework.EF CSFrameworkV1学习版 CSFrameworkV2标准版 CSFrameworkV3高级版 CSFrameworkV4企业版 CSFrameworkV5旗舰版 CSFrameworkV6.0 CSFrameworkV6.1 CSFrameworkV6旗舰版 DAL数据访问层 Database datalock DbFramework Demo教学 Demo实例 Demo下载 DevExpress教程 Docker Desktop DOM EFCore EF框架 Element-UI EntityFramework ERP ES6 Excel FastReport GIT HR IDatabase IIS JavaScript LINQ MES MiniFramework MIS MySql NavBarControl NETCore Node.JS NPM OMS Oracle资料 ORM PaaS POS Promise API PSD RedGet Redis SAP Schema SEO SEO文章 SQL SQLConnector SqlServer Swagger TMS系统 Token令牌 VS2022 VSCode VS升级 VUE WCF WebApi WebApi NETCore WebApi框架 WEB开发框架 Windows服务 Winform 开发框架 Winform 开发平台 WinFramework Workflow工作流 Workflow流程引擎 XtraReport 安装环境 版本区别 报表 备份还原 踩坑日记 操作手册 达梦数据库 代码生成器 迭代开发记录 功能介绍 国际化 基础资料窗体 架构设计 角色权限 开发sce 开发工具 开发技巧 开发教程 开发框架 开发平台 开发指南 客户案例 快速搭站系统 快速开发平台 框架升级 毛衫行业ERP 秘钥 密钥 权限设计 软件报价 软件测试报告 软件加壳 软件简介 软件开发框架 软件开发平台 软件开发文档 软件授权 软件体系架构 软件下载 软件著作权登记证书 软著证书 三层架构 设计模式 生成代码 实用小技巧 视频下载 收钱音箱 数据锁 数据同步 微信小程序 未解决问题 文档下载 喜鹊ERP 喜鹊软件 系统对接 详细设计说明书 新功能 信创 行政区域数据库 需求分析 疑难杂症 蝇量级框架 蝇量框架 用户管理 用户开发手册 用户控件 在线支付 纸箱ERP 智能语音收款机 自定义窗体 自定义组件 自动升级程序
联系我们
联系电话:13923396219(微信同号)
电子邮箱:23404761@qq.com
站长微信二维码
微信二维码