瀏覽代碼

修改language工具类获取不到ContextMenuStrip的bug

CXS 3 年之前
父節點
當前提交
ed47e14b85
共有 1 個文件被更改,包括 14 次插入7 次删除
  1. 14 7
      OTSSysMgrTools/Language.cs

+ 14 - 7
OTSSysMgrTools/Language.cs

@@ -74,14 +74,21 @@ namespace OTSSysMgrTools
                 for (int i = 0; i < fieldInfo.Length; i++)
                 for (int i = 0; i < fieldInfo.Length; i++)
                 {
                 {
                    
                    
-                    if (fieldInfo[i].FieldType.Name == "ContextMenuStrip")
+                    //if (fieldInfo[i].FieldType.Name == "ContextMenuStrip")
+                    //{
+                    //    ContextMenuStrip contextMenuStrip = (ContextMenuStrip)fieldInfo[i].GetValue(form);
+                    //    for (int j = 0; j < contextMenuStrip.Items.Count; j++)
+                    //    {
+                    //        if (table.Contains(contextMenuStrip.Items[j].Name.ToLower()))
+                    //            contextMenuStrip.Items[j].Text = (string)table[contextMenuStrip.Items[j].Name.ToLower()];
+                    //    }
+                    //}
+
+                    if(fieldInfo[i].FieldType.Name == "ToolStripMenuItem")
                     {
                     {
-                        ContextMenuStrip contextMenuStrip = (ContextMenuStrip)fieldInfo[i].GetValue(form);
-                        for (int j = 0; j < contextMenuStrip.Items.Count; j++)
-                        {
-                            if (table.Contains(contextMenuStrip.Items[j].Name.ToLower()))
-                                contextMenuStrip.Items[j].Text = (string)table[contextMenuStrip.Items[j].Name.ToLower()];
-                        }
+                        ToolStripMenuItem toolStripMenuItem=(ToolStripMenuItem)fieldInfo[i].GetValue(form);
+                        if (table.Contains(fieldInfo[i].Name.ToLower()))
+                            toolStripMenuItem.Text = (string)table[fieldInfo[i].Name.ToLower()];
                     }
                     }
                     
                     
                 }
                 }