找出两个窗口形式之间的差异

时间:2014-09-01 10:12:59

标签: c# visual-studio

我有两个xml个文件,它们的结构相同,解析一个的代码在这里:

    private void button1_Click(object sender, EventArgs e)
    {


        var root = XElement.Load(@"C:\Users\am\Desktop\_albana\ev_projects.xml");
        var controlElements = root.Descendants("CONTROL");

        var root1 = XElement.Load(@"C:\Users\am\Desktop\_albana\ev_projects_modified.xml");
        var controlElements1 = root.Descendants("CONTROL");


        int labelCounter = 1;
        foreach (var element in controlElements)
        {
            var labelId = (string)element.Attribute("LABEL_D");
            var textBoxName = (string)element.Attribute("LABEL_D");


            Label label = new Label();
            label.Text = (string)element.Attribute("LABEL_D");

            label.Left = 10;
            label.Top = (labelCounter + 1) * 20;

            TextBox textBox = new TextBox();

            textBox.Left = 120;
            textBox.Top = (labelCounter + 1) * 20;
            textBox.Text = (string)element.Attribute("ATTRIBUTE");


            this.Controls.Add(label);
            this.Controls.Add(textBox);

            labelCounter++;
        }


        foreach (var element in controlElements1)
        {
            var labelId1 = (string)element.Attribute("LABEL_D");
            var textBoxName1 = (string)element.Attribute("LABEL_D");


            Label label1 = new Label();
            label1.Text = (string)element.Attribute("LABEL_D");

            label1.Left = 10;
            label1.Top = (labelCounter + 1) * 20;

            TextBox textBox1 = new TextBox();

            textBox1.Left = 120;
            textBox1.Top = (labelCounter + 1) * 20;
            textBox1.Text = (string)element.Attribute("ATTRIBUTE");


            this.Controls.Add(label1);
            this.Controls.Add(textBox1);

            labelCounter++;
        }



    }

因此,当我看到我将两个xml文件加载到表单中时,我需要将labelId1labelId进行比较,如果它们相同,我会看到相应的{{1} } .Text和textBox1。文本,如果它们不同,我应该突出显示它们。 有什么想法吗?

0 个答案:

没有答案