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

网站推广的主题电子商务培训

网站推广的主题,电子商务培训,做网站前端程序员,房山区网站建设用C#窗体 写一个人性化的.ini文件 的配置工具。 打开界面时读ini配置到界面各控件,界面上的控件根据ini文件内容自动生成,点保存时把界面各控件的值写到ini里。 通用 using FT_Tools; using System; using System.Collections.Generic; using System.…

用C#窗体 写一个人性化的.ini文件 的配置工具。 打开界面时读ini配置到界面各控件,界面上的控件根据ini文件内容自动生成,点保存时把界面各控件的值写到ini里。
在这里插入图片描述

通用

using FT_Tools;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;public class ConfigForm : Form
{private Dictionary<Control, Tuple<string, string>> controlMap = new Dictionary<Control, Tuple<string, string>>();private Button btnSave = new Button { Text = "保存", Dock = DockStyle.Bottom };private Panel panel = new Panel { Dock = DockStyle.Fill, AutoScroll = true };public ConfigForm(){Text = "设置";WindowState = FormWindowState.Maximized;LoadConfig();btnSave.Click += (s, e) => SaveConfig();Controls.Add(panel);Controls.Add(btnSave);}private void LoadConfig(){var data = Program.myIni.ReadAll();int y = 10;foreach (var section in data){foreach (var kv in section.Value){Label lbl = new Label { Text = kv.Key, Left = 10, Top = y, AutoSize = true };Control inputControl;if (bool.TryParse(kv.Value, out bool boolValue)){inputControl = new CheckBox { Checked = boolValue, Left = 180, Top = y };}//else if (int.TryParse(kv.Value, out int intValue))//{//    inputControl = new NumericUpDown { Value = intValue, Left = 100, Top = y };//}else{inputControl = new TextBox { Text = kv.Value, Left = 180, Top = y, Width = 700 };}controlMap[inputControl] = Tuple.Create(section.Key, kv.Key);panel.Controls.Add(lbl);panel.Controls.Add(inputControl);y += 25;}}}private void SaveConfig(){foreach (var kv in controlMap){string value;if (kv.Key is TextBox tb){value = tb.Text;}else if (kv.Key is NumericUpDown num){value = num.Value.ToString();}else if (kv.Key is CheckBox cb){value = cb.Checked.ToString();}else{value = "";}Program.myIni.Write(kv.Value.Item1, kv.Value.Item2, value);}MessageBox.Show("配置已保存!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);//重启自己Application.Restart();}
}

并能定制控制

using FT_Tools;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;public class ConfigFormF200CKD : Form
{private Dictionary<Control, Tuple<string, string>> controlMap = new Dictionary<Control, Tuple<string, string>>();private Button btnSave = new Button { Text = "保存", Dock = DockStyle.Bottom };private Panel panel = new Panel { Dock = DockStyle.Fill, AutoScroll = true };public ConfigFormF200CKD(){Text = "设置";WindowState = FormWindowState.Maximized;LoadConfig();btnSave.Click += (s, e) => SaveConfig();Controls.Add(panel);Controls.Add(btnSave);}private void LoadConfig(){var data = Program.myIni.ReadAll();int y = 10;foreach (var section in data){foreach (var kv in section.Value){Label lbl = new Label { Text = kv.Key, Left = 10, Top = y, AutoSize = true };Control inputControl;if (bool.TryParse(kv.Value, out bool boolValue)){inputControl = new CheckBox { Checked = boolValue, Left = 150, Top = y };}//else if (int.TryParse(kv.Value, out int intValue))//{//    inputControl = new NumericUpDown { Value = intValue, Left = 100, Top = y };//}else{inputControl = new TextBox { Text = kv.Value, Left = 150, Top = y, Width = 400 };}controlMap[inputControl] = Tuple.Create(section.Key, kv.Key);panel.Controls.Add(lbl);panel.Controls.Add(inputControl);{ //定制配置if (kv.Key == "mysql数据库IP"){Button btn1 = new Button { Text = "测试", Left = inputControl.Right + 10, Top = y, Width = 100 };btn1.Click += (s, e) => { inputControl.Text = "192.168.8.240"; };panel.Controls.Add(btn1);Button btn2 = new Button { Text = "工厂", Left = inputControl.Right + 10 + 100 + 10, Top = y };btn2.Click += (s, e) => { inputControl.Text = "rm-8vbikz8103zit0xgs3o.mysql.zhangbei.rds.aliyuncs.com"; };panel.Controls.Add(btn2);}else if (kv.Key == "型号"){Button btn1 = new Button { Text = "F100CKD", Left = inputControl.Right + 10, Top = y, Width = 100 };btn1.Click += (s, e) => { inputControl.Text = btn1.Text; };panel.Controls.Add(btn1);Button btn2 = new Button { Text = "F200CKD", Left = inputControl.Right + 10 + 100 + 10, Top = y };btn2.Click += (s, e) => { inputControl.Text = btn2.Text; };panel.Controls.Add(btn2);}else if (kv.Key == "物料标签模板DateCode" || kv.Key.Contains("模板")) //选择一个文件{Button btn1 = new Button { Text = "浏览", Left = inputControl.Right + 10, Top = y, Width = 100 };btn1.Click += (s, e) => {OpenFileDialog openFileDialog = new OpenFileDialog{Title = "选择文件",Filter = "所有文件|*.*|文本文件|*.txt|图片文件|*.jpg;*.png;*.gif",InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)};if (openFileDialog.ShowDialog() == DialogResult.OK){string selectedFilePath = openFileDialog.FileName;//MessageBox.Show("你选择的文件路径是: " + selectedFilePath);inputControl.Text = selectedFilePath;}};panel.Controls.Add(btn1);}}y += 25;}}}private void SaveConfig(){foreach (var kv in controlMap){string value;if (kv.Key is TextBox tb){value = tb.Text;}else if (kv.Key is NumericUpDown num){value = num.Value.ToString();}else if (kv.Key is CheckBox cb){value = cb.Checked.ToString();}else{value = "";}Program.myIni.Write(kv.Value.Item1, kv.Value.Item2, value);}MessageBox.Show("配置已保存!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);//重启自己Application.Restart();}
}
http://www.dtcms.com/wzjs/529499.html

相关文章:

  • 网站设计与制作的流程必应搜索网站
  • 怎么建公司网站教程芒果视频怎样下载到本地
  • 普通人找工作哪个网站好外贸网站建设优化
  • 做html网站上海seo网络优化
  • 色块网站网站的收录情况怎么查
  • 梅州建站公司网址查询
  • 做百度网站要注意什么网站运营优化培训
  • 惠州网站制作定制seo在线培训机构
  • 做的好详情页网站广州百度关键词推广
  • wordpress 三级分类aso优化是什么意思
  • 网站在线答题怎么做热狗seo顾问
  • 汕头网站建设工作网站模板搭建
  • 合肥 电子商务 网站建设爱链网买链接
  • 网站建设合同 下载网站查询seo
  • 免费手机wap网站精准引流推广团队
  • WordPress添加进度条南京百度推广优化
  • 思途做的旅游网站淘宝宝贝排名查询
  • 广源建设集团有限公司网站关键词查找
  • 大学网站建设专业自助建站系统平台
  • 怎么做挖矿网站云搜索下载
  • 如何自己做网站界面淘宝关键词优化
  • 网站建设 博客企业所得税优惠政策
  • 大棚网站建设应用商店aso
  • 政府网站建设费用明细广州今日头条新闻最新
  • 尊园地产做的网站东莞网络营销平台
  • 软件代做网站在哪找活株洲网络推广
  • 电子商务网站建设与管理期末考试百度销售岗位怎么样
  • 陕西省城乡建设厅官方网站列举网络推广的方式
  • 行政助手网站开发南京网络优化培训
  • 动态网站订单怎么做百度推广助手客户端