综合查询系统

动态配置查询控件

动态配置查询条件

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);

 

呵呵

你可能感兴趣的:(综合查询系统)