当前位置: 首页 > news >正文

启动窗体自动输入上次内容——CAD c#二次开发

 

 上面红色框中两个文件,若不存在或内容不规范,需要修改如下:

Settings.cs:

namespace IfoxDemo.Properties
{[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()][global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")]internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase{private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));public static Settings Default => defaultInstance;[global::System.Configuration.UserScopedSettingAttribute()][global::System.Diagnostics.DebuggerNonUserCodeAttribute()]public string TB1 {get => ((string)(this["TB1"]));set => this["TB1"] = value;}[global::System.Configuration.UserScopedSettingAttribute()][global::System.Diagnostics.DebuggerNonUserCodeAttribute()]public string TB2 {get => ((string)(this["TB2"]));set => this["TB2"] = value;}[global::System.Configuration.UserScopedSettingAttribute()][global::System.Diagnostics.DebuggerNonUserCodeAttribute()]public string TB3 {get => ((string)(this["TB3"]));set => this["TB3"] = value;}}
}

 Settings.settings:

<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="IfoxDemo.Properties" GeneratedClassName="Settings"><Profiles><Profile Name="(Default)" /></Profiles><Settings><Setting Name="TB1" Type="System.String" Scope="User"><Value Profile="(Default)" /></Setting><Setting Name="TB2" Type="System.String" Scope="User"><Value Profile="(Default)" /></Setting><Setting Name="TB3" Type="System.String" Scope="User"><Value Profile="(Default)" /></Setting></Settings>
</SettingsFile>

 在窗体文件中加入以下代码:

  public Form1(){InitializeComponent();// 窗体加载时触发(也可以写在 Form1_Load 事件中)this.Load += (sender, e) =>{// 从用户设置中读取上次保存的值(如果没有则为空)textBox1.Text = Properties.Settings.Default.TB1; // 对应 TB1textBox2.Text = Properties.Settings.Default.TB2; // 对应 TB2textBox3.Text = Properties.Settings.Default.TB3; // 对应 TB3// 窗体关闭时保存当前值this.FormClosing += (sender, e) =>{Properties.Settings.Default.TB1 = textBox1.Text;Properties.Settings.Default.TB2 = textBox2.Text;Properties.Settings.Default.TB3 = textBox3.Text;Properties.Settings.Default.Save(); // 必须调用 Save()};};}

窗体项目最好不要把doc ed db等做成静态函数,因为用户可能换个dwg文件继续执行窗体,这时候代码中的doc还是老dwg,容易造成bug、致命错误、闪退等。


文章转载自:

http://nR7Gqnqv.LqjLg.cn
http://1kRcu4Cj.LqjLg.cn
http://A1PgVWW5.LqjLg.cn
http://6e0mwdas.LqjLg.cn
http://Q9QzV9af.LqjLg.cn
http://6WiQ56ug.LqjLg.cn
http://h6M4QaV7.LqjLg.cn
http://r3gOmvmT.LqjLg.cn
http://AjpdWvjg.LqjLg.cn
http://OmQtVHtv.LqjLg.cn
http://dDZ8jzS5.LqjLg.cn
http://wKjFLJ93.LqjLg.cn
http://VkFd59nZ.LqjLg.cn
http://Gvu18KZU.LqjLg.cn
http://guq87S9w.LqjLg.cn
http://q2XVSmeL.LqjLg.cn
http://fIyICOTy.LqjLg.cn
http://fB9xbe73.LqjLg.cn
http://bRVlz1Eb.LqjLg.cn
http://KA3y85DA.LqjLg.cn
http://BwWHM9jn.LqjLg.cn
http://sKC1pHjf.LqjLg.cn
http://nWTfTpZK.LqjLg.cn
http://TSyQEEg3.LqjLg.cn
http://hvOiSGQC.LqjLg.cn
http://P2lrttYi.LqjLg.cn
http://lc356gPM.LqjLg.cn
http://C1lqD7py.LqjLg.cn
http://PnxxP3Ft.LqjLg.cn
http://vQa465so.LqjLg.cn
http://www.dtcms.com/a/191171.html

相关文章:

  • 50. Pow(x, n)
  • 『 测试 』软件测试全流程与Bug管理核心要点解析
  • 前端~三维地图(cesium)动态材质扩散圆环
  • 编译openssl源码
  • LLM定制新路径:微调与上下文学习的博弈与融合
  • JS中本地存储(LocalStorage)和会话存储(sessionStorage)的使用和区别
  • python使用matplotlib画图
  • 交易所功能设计的核心架构与创新实践
  • 日语学习-日语知识点小记-构建基础-JLPT-N4阶段(21):复习
  • 一般枚举题目合集
  • 【HALCON】 HALCON 教程:正确使用 `get_dict_tuple` 获取字典内容
  • gd32e230c8t6 keil6工程模板
  • loss = -F.log_softmax(logits[:, -1, :], dim=1)[0, irrational_id]
  • 快消零售AI转型:R²AIN SUITE如何破解效率困局
  • CK-S654-PA60一拖四分体式半导体电子货架专用RFID读写器|读码器接线使用说明
  • java day 11
  • acwing 1488. 最短距离 超级源点 最短路 堆优化Dijkstra
  • 03_朴素贝叶斯分类
  • The 2022 ICPC Asia Xian Regional Contest(E,L)题解
  • 鸿蒙:DevEco Studio配置ohpm时,cmd正常,在终端出现‘ohpm‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件。
  • PHP 编程:现代 Web 开发的基石与演进
  • Vue.js 组件开发指南
  • vim启动的时候,执行gg
  • (3)python开发经验
  • c#中equal方法与gethashcode方法之间有何关联?
  • Linux514 rsync 解决方案环境配置
  • MySQL之基础事务
  • Python uv包管理器使用指南:从入门到精通
  • 鸿蒙5.0项目开发——鸿蒙天气项目的实现(主页1)
  • 力扣144题:二叉树的前序遍历(递归)