肥宅综合社区-做一个优雅文明的综合社区

搜索内容

C# Winform获取常规控件&容器控件&特殊容器控件 及其子容器属性代码

2023-10-04 284阅读 0评论

虽然方法比较笨,但是最终还是搞定了

  1. using System.Windows.Forms;

  2. namespace DianZan.sOptions
  3. {
  4.     class AddOptionInfo
  5.     {
  6.         public static void colButton(Button cl)
  7.         {
  8.             object cTag = cl.Tag;
  9.             string cName = cl.Name;
  10.             string cText = cl.Text;
  11.             object cValue = cl.Text;
  12.             AddData(cTag, cName, cText, cValue);
  13.         }

  14.         public static void colCheckBoxx(CheckBox cl)
  15.         {
  16.             object cTag = cl.Tag;
  17.             string cName = cl.Name;
  18.             string cText = cl.Text;
  19.             object cValue = cl.Checked;
  20.             AddData(cTag, cName, cText, cValue);
  21.         }

  22.         public static void colComboBox(ComboBox cl)
  23.         {
  24.             object cTag = cl.Tag;
  25.             string cName = cl.Name;
  26.             string cText = cl.Text;
  27.             object cValue = cl.Text;
  28.             AddData(cTag, cName, cText, cValue);
  29.         }

  30.         public static void colGroupBoxExt(GroupBoxExt cl)
  31.         {
  32.             object cTag = cl.Tag;
  33.             string cName = cl.Name;
  34.             string cText = cl.Text;
  35.             object cValue = cl.Text;
  36.             AddData(cTag, cName, cText, cValue);
  37.         }

  38.         public static void colLabel(Label cl)
  39.         {
  40.             object cTag = cl.Tag;
  41.             string cName = cl.Name;
  42.             string cText = cl.Text;
  43.             object cValue = cl.Text;
  44.             AddData(cTag, cName, cText, cValue);
  45.         }

  46.         public static void colStatusStrip(StatusStrip cl)
  47.         {
  48.             object cTag = cl.Tag;
  49.             string cName = cl.Name;
  50.             string cText = cl.Text;
  51.             object cValue = cl.Text;
  52.             AddData(cTag, cName, cText, cValue);
  53.         }

  54.         public static void colTextBox(TextBox cl)
  55.         {
  56.             object cTag = cl.Tag;
  57.             string cName = cl.Name;
  58.             string cText = cl.Text;
  59.             object cValue = cl.Text;
  60.             AddData(cTag, cName, cText, cValue);
  61.         }

  62.         public static void colToolStripItem(ToolStripItem cl)
  63.         {
  64.             object cTag = cl.Tag;
  65.             string cName = cl.Name;
  66.             string cText = cl.Text;
  67.             object cValue = cl.Text;
  68.             AddData(cTag, cName, cText, cValue);
  69.         }

  70.         public static void colToolStripDropDownButton(ToolStripDropDownButton cl)
  71.         {
  72.             object cTag = cl.Tag;
  73.             string cName = cl.Name;
  74.             string cText = cl.Text;
  75.             object cValue = cl.Text;
  76.             AddData(cTag, cName, cText, cValue);
  77.         }

  78.         public static void colToolStripMenuItem(ToolStripMenuItem cl)
  79.         {
  80.             object cTag = cl.Tag;
  81.             string cName = cl.Name;
  82.             string cText = cl.Text;
  83.             object cValue = cl.Text;
  84.             AddData(cTag, cName, cText, cValue);
  85.         }

  86.         public static void colToolStripStatusLabel(ToolStripStatusLabel cl)
  87.         {
  88.             object cTag = cl.Tag;
  89.             string cName = cl.Name;
  90.             string cText = cl.Text;
  91.             object cValue = cl.Text;
  92.             AddData(cTag, cName, cText, cValue);
  93.         }

  94.         public static void colToolStripProgressBar(ToolStripProgressBar cl)
  95.         {
  96.             object cTag = cl.Tag;
  97.             string cName = cl.Name;
  98.             string cText = cl.Text;
  99.             object cValue = cl.Text;
  100.             AddData(cTag, cName, cText, cValue);
  101.         }

  102.         public static void colToolStripSplitButton(ToolStripSplitButton cl)
  103.         {
  104.             object cTag = cl.Tag;
  105.             string cName = cl.Name;
  106.             string cText = cl.Text;
  107.             object cValue = cl.Text;
  108.             AddData(cTag, cName, cText, cValue);
  109.         }

  110.         private static void AddData(object cTag,string cName,string cText,object cValue)
  111.         {
  112.             //Type typec = con.GetType();
  113.             bool LangSave = false;
  114.             bool OptSave = false;
  115.             if (cTag != null && cTag.Equals("Lang"))
  116.             {
  117.                 LangSave = true;                                         //是否包含保存配置参数标志
  118.             }
  119.             if (cTag != null && cTag.Equals("Opt"))
  120.             {
  121.                 OptSave = true;                                         //是否包含保存配置参数标志
  122.             }
  123.             if (cTag != null && cTag.Equals("LangOpt"))
  124.             {
  125.                 LangSave = true;
  126.                 OptSave = true;
  127.             }

  128.             LangOption langOption = new LangOption();
  129.             CtrOption ctrOption = new CtrOption();

  130.             if (LangSave)
  131.             {
  132.                 langOption.Name = cName;
  133.                 langOption.Text = cText;
  134.                 OptionData.LangList.Add(langOption);                //添加语言文件
  135.             }
  136.             if (OptSave)
  137.             {
  138.                 ctrOption.Name = cName;
  139.                 ctrOption.Value = cValue;
  140.                 OptionData.CtrList.Add(ctrOption);                  //添加语言文件
  141.             }

  142.         }
  143.     }
  144. }

文章版权声明:本站部分内容系网络转载,如果文章触发到您的利益或版权,请联系本站客服邮箱kefu@fz331.com删除,我们将48小时之内删除。

发表评论

上传附件:
评论列表 (有 0 条评论,284人围观)
切换注册

登录

忘记密码?

切换登录

注册

验证码