当前位置:编程学习 > C#/ASP.NET >>

大家帮看下这个代码的是什么意思?

public void SetDataFromForm(System.Windows.Forms.Form TheForm)
        {
            PropertyInfo[] PList = this.GetPorperties();
            for (int i = 0; i < PList.GetLength(0); i++)
            {
                System.Windows.Forms.Control[] CList = TheForm.Controls.Find("textBox_" + PList[i].Name, true);
                if (CList.GetLength(0) == 1)
                {
                    if (CList[0].ToString().Contains("System.Windows.Forms.ComboBox"))
                    {
                        this.SetPorpertyValue(PList[i].Name, ((ComboBox)CList[0]).SelectedValue.ToString());
                    }
                    else if (CList[0].ToString().Contains("System.Windows.Forms.DateTimePicker"))
                    {
                        this.SetPorpertyValue(PList[i].Name, ((DateTimePicker)CList[0]).Value);
                    }
                    else if (CList[0].ToString().Contains("System.Windows.Forms.NumericUpDown"))
                    {
                        this.SetPorpertyValue(PList[i].Name, ((NumericUpDown)CList[0]).Value.ToString());
                    }
                    else
                    {
                        this.SetPorpertyValue(PList[i].Name, CList[0].Text);
                    }
                }
            }
        } --------------------编程问答-------------------- Set Data From Form <- 方法名起得还好,应该是把Form上的输入值赋给一个实体的。 --------------------编程问答-------------------- 根据Form上的空间的值,然后运用反射赋值的,
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,