void companyControl1_MouseUp(object sender, MouseEventArgs e) { panel1.Cursor = Cursors.Default; CompanyControl nv = new CompanyControl(); nv.Location = vitri; panelControl1.Controls.Add(nv); ControlMover.Init(nv); nv.MouseUp += companyControl1_MouseUp; nv.MouseDown += companyControl1_MouseDown; TimChaConMoi((CompanyControl)sender); }
public Form1() { InitializeComponent(); DBEngine.Server = Khoidau.Servername; DBEngine.User = Khoidau.User; DBEngine.Password = Khoidau.Password; DBEngine.Database = Khoidau.Dtname; DBEngine.open(); //Set su kien Mousemove GlobalMouseHandler gmh = new GlobalMouseHandler(); gmh.TheMouseMoved += new MouseMovedEvent(gmh_TheMouseMoved); Application.AddMessageFilter(gmh); //End set su kien Mousemove ControlMover.Init(companyControl1); vitri = companyControl1.Location; //Set kich thuoc Form(Neu ko co 2 dong nay bieu do se mat net) this.Width = Screen.PrimaryScreen.Bounds.Width; this.Height = Screen.PrimaryScreen.Bounds.Height - 50; }
CompanyControl CreateControl(string ten, string tagname, string tenhienthi, string tablename, string codename, int id, int parentID) { //Add CompanyControl CompanyControl lbltemp = new CompanyControl(); lbltemp.Name = ten; lbltemp.Tag = tagname; lbltemp.Size = new Size(rong, cao); lbltemp.BackColor = cl1; lbltemp.Text = tenhienthi; lbltemp.tentable = tablename; lbltemp.txtcode = codename; lbltemp.txtname = tenhienthi; lbltemp.ID = id; lbltemp.ParentID = parentID; lbltemp.txtCode.GotFocus += lbltemp_Click; lbltemp.txtName.GotFocus += lbltemp_Click; lbltemp.EnabledChanged += lbltemp_EnabledChanged; lbltemp.MouseUp += lbltemp_MouseUp; lbltemp.MouseDown += lbltemp_MouseDown; lbltemp.MouseMove += lbltemp_MouseMove; ControlMover.Init(lbltemp, ControlMover.Direction.Horizontal); return(lbltemp); }