综合查询系统

    技术2022-05-20  46

    动态配置查询控件

    动态配置查询条件

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

     

    呵呵


    最新回复(0)