C# Winform获取常规控件&容器控件&特殊容器控件 及其子容器属性代码
虽然方法比较笨,但是最终还是搞定了
- using System.Windows.Forms;
- namespace DianZan.sOptions
- {
- class AddOptionInfo
- {
- public static void colButton(Button cl)
- {
- object cTag = cl.Tag;
- string cName = cl.Name;
- string cText = cl.Text;
- object cValue = cl.Text;
- AddData(cTag, cName, cText, cValue);
- }
- public static void colCheckBoxx(CheckBox cl)
- {
- object cTag = cl.Tag;
- string cName = cl.Name;
- string cText = cl.Text;
- object cValue = cl.Checked;
- AddData(cTag, cName, cText, cValue);
- }
- public static void colComboBox(ComboBox cl)
- {
- object cTag = cl.Tag;
- string cName = cl.Name;
- string cText = cl.Text;
- object cValue = cl.Text;
- AddData(cTag, cName, cText, cValue);
- }
- public static void colGroupBoxExt(GroupBoxExt cl)
- {
- object cTag = cl.Tag;
- string cName = cl.Name;
- string cText = cl.Text;
- object cValue = cl.Text;
- AddData(cTag, cName, cText, cValue);
- }
- public static void colLabel(Label cl)
- {
- object cTag = cl.Tag;
- string cName = cl.Name;
- string cText = cl.Text;
- object cValue = cl.Text;
- AddData(cTag, cName, cText, cValue);
- }
- public static void colStatusStrip(StatusStrip cl)
- {
- object cTag = cl.Tag;
- string cName = cl.Name;
- string cText = cl.Text;
- object cValue = cl.Text;
- AddData(cTag, cName, cText, cValue);
- }
- public static void colTextBox(TextBox cl)
- {
- object cTag = cl.Tag;
- string cName = cl.Name;
- string cText = cl.Text;
- object cValue = cl.Text;
- AddData(cTag, cName, cText, cValue);
- }
- public static void colToolStripItem(ToolStripItem cl)
- {
- object cTag = cl.Tag;
- string cName = cl.Name;
- string cText = cl.Text;
- object cValue = cl.Text;
- AddData(cTag, cName, cText, cValue);
- }
- public static void colToolStripDropDownButton(ToolStripDropDownButton cl)
- {
- object cTag = cl.Tag;
- string cName = cl.Name;
- string cText = cl.Text;
- object cValue = cl.Text;
- AddData(cTag, cName, cText, cValue);
- }
- public static void colToolStripMenuItem(ToolStripMenuItem cl)
- {
- object cTag = cl.Tag;
- string cName = cl.Name;
- string cText = cl.Text;
- object cValue = cl.Text;
- AddData(cTag, cName, cText, cValue);
- }
- public static void colToolStripStatusLabel(ToolStripStatusLabel cl)
- {
- object cTag = cl.Tag;
- string cName = cl.Name;
- string cText = cl.Text;
- object cValue = cl.Text;
- AddData(cTag, cName, cText, cValue);
- }
- public static void colToolStripProgressBar(ToolStripProgressBar cl)
- {
- object cTag = cl.Tag;
- string cName = cl.Name;
- string cText = cl.Text;
- object cValue = cl.Text;
- AddData(cTag, cName, cText, cValue);
- }
- public static void colToolStripSplitButton(ToolStripSplitButton cl)
- {
- object cTag = cl.Tag;
- string cName = cl.Name;
- string cText = cl.Text;
- object cValue = cl.Text;
- AddData(cTag, cName, cText, cValue);
- }
- private static void AddData(object cTag,string cName,string cText,object cValue)
- {
- //Type typec = con.GetType();
- bool LangSave = false;
- bool OptSave = false;
- if (cTag != null && cTag.Equals("Lang"))
- {
- LangSave = true; //是否包含保存配置参数标志
- }
- if (cTag != null && cTag.Equals("Opt"))
- {
- OptSave = true; //是否包含保存配置参数标志
- }
- if (cTag != null && cTag.Equals("LangOpt"))
- {
- LangSave = true;
- OptSave = true;
- }
- LangOption langOption = new LangOption();
- CtrOption ctrOption = new CtrOption();
- if (LangSave)
- {
- langOption.Name = cName;
- langOption.Text = cText;
- OptionData.LangList.Add(langOption); //添加语言文件
- }
- if (OptSave)
- {
- ctrOption.Name = cName;
- ctrOption.Value = cValue;
- OptionData.CtrList.Add(ctrOption); //添加语言文件
- }
- }
- }
- }
文章版权声明:本站部分内容系网络转载,如果文章触发到您的利益或版权,请联系本站客服邮箱kefu@fz331.com删除,我们将48小时之内删除。
发表评论