双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

Winform user control does not create designer code after user's edit?WinForm自定义控件编辑结果不在窗体代码生成?

weixin_38071769 weixin_38071769 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我创建了一个名称为MSTagServer的自定义控件,其中有个属性为SavedTagsList,给用户提供弹出窗体编辑需要确认的勾选项。为了能记住用户的勾选项,我想再窗体代码内进行生成,问题是编辑完毕后,窗体代码没有任何的变化。测试过程中,我发现只要移除[Editor(typeof(SavedTagSelectDropDownEditor)这段属性代码,用VS标准的方式编辑,每次关闭,均能在设计器中产生代码记忆编辑内容,但是为何用自定义的编辑窗体就不行呢?

I create a user control named MSTagServer.the control have a property named SavedTagsList which show user the UITypeEditor window to check saved tags.the problem is the desiger does not generate any code like
this.msTagServer1.SavedTagsList.Add(((Advantech.MSControl.SavedTag)(resources.GetObject("msTagServer1.SavedTagsList"))));if I remove the line [Editor(typeof(SavedTagSelectDropDownEditor), typeof(UITypeEditor))],the vs will generate designer codeas soon as the edit windown close.so,what's the problem?why the user's UITypeEditor can not trigger the form deigner?控件代码
public partial class MSTagServer : Component private List<SavedTag> _list = new List<SavedTag>(); [Editor(typeof(SavedTagSelectDropDownEditor), typeof(UITypeEditor))] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public List<SavedTag> SavedTagsList { set { _list = value; if (_list != null && Common.EditEnvironmentCheck() == false)//not edit mode,mark { if (TagList.TagsDic.Count > 0) { foreach (SavedTag item in _list) { TagGroup grp = TagList.TagsDic[item.TagGroupName]; Tag tag = grp.Tags.Find(x => x.TagName.Equals(item.TagName)); tag.SaveToFile = true; } } } } get { return _list; } }
弹出窗体编辑器
public class SavedTagSelectDropDownEditor : System.Drawing.Design.UITypeEditor { public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) { if (context != null && context.Instance != null) { return UITypeEditorEditStyle.Modal; } return base.GetEditStyle(context); } public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { IWindowsFormsEditorService editorService = null; if (context != null && context.Instance != null && provider != null) { editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (editorService != null) { MSTagServer ts = (MSTagServer)context.Instance; if (ts != null) { FrmTagSelectControl ctrl = new FrmTagSelectControl(ts.TagDic, ts.SavedTagsList); DialogResult res = editorService.ShowDialog(ctrl);//show user's edit window if (res == DialogResult.OK) { value = ctrl.SavedTagsList; return value; } } } } return value; } }
需要存储在设计器中的类
[Serializable] public class SavedTag { public string TagGroupName { set; get; } public string TagName { set; get; } }



...全文

相关推荐

VS2019 C# Winform如何生成exe和msi安装包.pdf

VS2019 C# Winform如何生成exe和msi安装包.pdf 具体的内容可以参见博客内容,PDF内容与博客同名文章内容一致。

share-learning

C# Winform用户权限系统设计:从登录到角色权限与日志的完整实践

在企业级内部系统开发中,基于角色的访问控制(RBAC)是权限管理的基础模型,它将用户、角色与操作权限解耦,支持细粒度的按钮级控制。理解RBAC的原理有助于构建可扩展的安全体系。在C# Winform桌面应用里,权限管理不仅要实现用户登录,更要将用户创建、角色分配、操作权限设置及审计日志贯穿于数据库设计和界面交互中。通过合理的表结构、全局会话对象、动态控件权限回收及日志埋点,开发者可以构建一套可复用的用户权限管理模块,适用于MIS系统、进销存及后台管理工具。本文将分享从零搭建这套体系的关键思路与常见问题,帮助

weixin_30808693

XNA_integration_inside_WPF

WPF内整合XNA By Valentin Billotte | 20 Jul 2009 另一种方法在WPF中整合多种XNA场景. There are many ways to display 3D scenes based on XNA in a WPF environment. Some suffer from problems of speed (with the use of WindowsFormHost), others allow only limited interaction with the WPF controls and interfaces. Implementing multiple displays as seen in programs like Maya becomes problematic

「已注销」

Dundas.Chart.for.Winform.Enterprise.v7.1.0.1812.for.VS2008

Add advanced charting to your ASP.NET applications. Dundas Chart ASP.NET Enterprise Edition is a fully managed, CLR (Common Language Runtime) compliant charting component designed for ASP.NET development. Included is support for all standard and many advanced chart types, drilldown functionality, full Visual Studio Integrated help, a variety of different image formats and intuitive samples and examples to speed up development time. Graphics take full advantage of GDI+ and the use of transparency, anti-aliasing, gradients and more. Dundas Chart for ASP.NET Enterprise Edition includes many advanced features including: formula support, data grouping, data filtering and advanced chart types. Dundas Chart for .NET is the industry leader in .NET Charting Solutions. Providing you with the most comprehensive features, the most complete sample framework, and the best live technical support available. From start to finish, our team is dedicated to providing what you need to make your project successful. Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced, award-winning technology and advanced results to get the most out of data What’s new in Dundas Chart for ASP.NET? Now supports Visual Studio 2010 What’s new in Dundas Chart V7.1? - V7.1 fixes these issues: AlwaysRecreateHotregions="True" in WinForms templates or templates generated by Chart Builder causes the Exception Can't deserialize property. Unknown property name "AlwaysRecreateHotregions" in object Dundas.Charting.WebControl.Chart" when de-serialized in ASP.NET Chart. This property only exists in the WinForms Chart. The ASP.NET Chart ignores this property by default now. Chart .NET: Stacked Column + 3D throws an Index was out of range exception when series have a different number of data points The accumulation distribution formula is incorrect; if open and close are the same it will divide by zero. A friendlier exception message is th

中山中盈科技

C#利用存储过程实现的 增加,删除,修改

本实例是winForm设计,主要通过存储过程实现增,删,改,同时基于C/S网络数据库连接模式。可作库初学者的范例。

dearstar
评论 2
收藏 已收藏
分享
返回顶部