public static void GetValueControlByJson(System.Windows.Forms.Control.ControlCollection control, string pathFile) { control.Clear(); var fieldControl = Newtonsoft.Json.JsonConvert.DeserializeObject <FieldControl>(File.ReadAllText(pathFile)); foreach (var p in fieldControl.propertyControl) { try { switch (p.TypeName) { #region GGTextEdit case "GreenGlobal.Qlxdcb.Component.GGTextEdit": { GGTextEdit ctrl = new GGTextEdit(); SetControlByProperties(ctrl, p); control.Add(ctrl); } break; #endregion #region GGLabel case "GreenGlobal.Qlxdcb.Component.GGLabel": { GGLabel ctrl = new GGLabel(); SetControlByProperties(ctrl, p); control.Add(ctrl); } break; #endregion #region GGComboBase case "GreenGlobal.Qlxdcb.Component.GGComboBase": { GGComboBase ctrl = new GGComboBase(); SetControlByProperties(ctrl, p); control.Add(ctrl); } break; #endregion #region GGCheckEdit case "GreenGlobal.Qlxdcb.Component.GGCheckEdit": { GGCheckEdit ctrl = new GGCheckEdit(); SetControlByProperties(ctrl, p); control.Add(ctrl); } break; #endregion } } catch { } } }
private void CheckboxTool_Click(object sender, EventArgs e) { Random rnd = new Random(); int randNumber = rnd.Next(1, 1000); String chkName = "chk_" + randNumber; GGCheckEdit ctrl = new GGCheckEdit(); ctrl.Location = new Point(30, 30); ctrl.Name = chkName; ctrl.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); ctrl.Text = "GGCheckEdit"; ctrl.BringToFront(); ctrl.MouseEnter += new EventHandler(control_MouseEnter); ctrl.MouseLeave += new EventHandler(control_MouseLeave); ctrl.MouseDown += new MouseEventHandler(control_MouseDown); ctrl.MouseMove += new MouseEventHandler(control_MouseMove); ctrl.MouseUp += new MouseEventHandler(control_MouseUp); pnControls.Controls.Add(ctrl); }