/// <summary> /// Handles the BtnClick event of the UCDropDownBtn control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> void UCDropDownBtn_BtnClick(object sender, EventArgs e) { if (_frmAnchor == null || _frmAnchor.IsDisposed || _frmAnchor.Visible == false) { if (Btns != null && Btns.Length > 0) { int intRow = 0; int intCom = 1; var p = this.PointToScreen(this.Location); while (true) { int intScreenHeight = Screen.PrimaryScreen.Bounds.Height; if ((p.Y + this.Height + Btns.Length / intCom * 50 < intScreenHeight || p.Y - Btns.Length / intCom * 50 > 0) && (_dropPanelHeight <= 0 ? true : (Btns.Length / intCom * 50 <= _dropPanelHeight))) { intRow = Btns.Length / intCom + (Btns.Length % intCom != 0 ? 1 : 0); break; } intCom++; } UCTimePanel ucTime = new UCTimePanel(); ucTime.IsShowBorder = true; int intWidth = this.Width / intCom; Size size = new Size(intCom * intWidth, intRow * 50); ucTime.Size = size; ucTime.FirstEvent = true; ucTime.SelectSourceEvent += ucTime_SelectSourceEvent; ucTime.Row = intRow; ucTime.Column = intCom; List <KeyValuePair <string, string> > lst = new List <KeyValuePair <string, string> >(); foreach (var item in Btns) { lst.Add(new KeyValuePair <string, string>(item, item)); } ucTime.Source = lst; _frmAnchor = new Forms.FrmAnchor(this, ucTime); _frmAnchor.Load += (a, b) => { (a as Form).Size = size; }; _frmAnchor.Show(this.FindForm()); } } else { _frmAnchor.Close(); } }
void ucTime_SelectSourceEvent(object sender, EventArgs e) { if (_frmAnchor != null && !_frmAnchor.IsDisposed && _frmAnchor.Visible) { SelectedValue = sender.ToString(); _frmAnchor.Close(); } }