void ClosePopup() { if (_isContentShown) { _parent.Controls.Remove(_floatingList); _floatingList.Dispose(); _floatingList = null; _isContentShown = false; } }
void OpenPopup() { if (Items.Count == 0) { return; } if (_isContentShown == false) { if (_floatingList == null) { _floatingList = new ContextListForm(); _floatingList.Width = (int)_maxWidth; Items.SetNormalFontColor(Brushes.Black); _floatingList.BackColor = Color.White; //background for (int i = 0; i < Items.Count; i++) { String text = Items.Keys.ElementAt(i) + ":" + Items.Values.ElementAt(i); _floatingList.Items.Add(text, Items.FontColor(i)); } _isContentShown = true; if (_timerOver.Enabled == false) { _timerOver.Start(); } Rectangle cellBounds = _parent.GetCellDisplayRectangle(this.ColumnIndex, this.RowIndex, false); Point pt2 = cellBounds.Location; pt2 = _parent.PointToScreen(pt2); _floatingList.Location = new Point(pt2.X, pt2.Y + cellBounds.Height); //_floatingList.TopMost = true; _floatingList.ResumeLayout(); _floatingList.Show(); _parent.Focus(); _floatingList.SetBounds(pt2.X, pt2.Y + cellBounds.Height, 0, 0, BoundsSpecified.Location); } } else { Rectangle cellBounds = _parent.GetCellDisplayRectangle(this.ColumnIndex, this.RowIndex, false); //Rectangle parentBounds = _parent.Bounds; Point pt2 = cellBounds.Location; pt2 = _parent.PointToScreen(pt2); _floatingList.SetBounds(pt2.X, pt2.Y + cellBounds.Height, 0, 0, BoundsSpecified.Location); } }