综合查询系统

来源:互联网 发布:外星人知乎 编辑:程序博客网 时间:2024/06/09 20:55

动态配置查询控件

动态配置查询条件

C#函数:

 

       函数 (string controlType, Form form, int positionX, int positionY)
        {

            try
            {
                string assemblyQualifiedName = typeof(System.Windows.Forms.Form).AssemblyQualifiedName;
                string assemblyInformation = assemblyQualifiedName.Substring(assemblyQualifiedName.IndexOf(","));
                Type ty = Type.GetType(controlType + assemblyInformation);
                Control newControl = (Control)System.Activator.CreateInstance(ty);
                form.SuspendLayout();
                newControl.Location = new System.Drawing.Point(positionX, positionY);
                newControl.Name = ty.Name + form.Controls.Count.ToString();
                form.Controls.Add(newControl);
                form.ResumeLayout();
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }

 

//使用

 

CreateControl("System.Windows.Forms.TextBox", this, 10, 10);

 

呵呵