protected override void OnTextChanged(EventArgs e) { base.OnTextChanged(e); if (_box != null) { if (this.Text != "") { _box.Items.Clear(); var legalStrings = from item in _autoCompleteSource where item.Name.ToUpper().StartsWith(this.Text.Trim().ToUpper()) select item.Name; if (legalStrings.Count <string>() > 0) { foreach (string str in legalStrings) { _box.Items.Add(str); } if (_dropDown != null && dropDownEnabled) { UpdateDropDownSize(); _dropDown.Show(this, new Point(0, this.Height)); _dropDown.AutoClose = true; } } else { _dropDown.Close(); } } else { _dropDown.Close(); } } }
// When user right-clicks the cell origin, it clears and fill the CheckedListBox with // columns header text. Then it shows the popup. // In this way the CheckedListBox items are always refreshed to reflect changes occurred in // DataGridView columns (column additions or name changes and so on). void mDataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.Button == MouseButtons.Right && e.RowIndex == -1 && e.ColumnIndex == -1) { mCheckedListBox.Items.Clear(); foreach (DataGridViewColumn c in mDataGridView.Columns) { if (Array.IndexOf(HiddenColumnName, c.HeaderText) < 0) { mCheckedListBox.Items.Add(c.HeaderText, c.Visible); } else { if (!SupressedColumns.Contains(c.HeaderText)) { mCheckedListBox.Items.Add(c.HeaderText, c.Visible); } else { mCheckedListBox.Items.Add(c.HeaderText, CheckState.Indeterminate); } } } int PreferredHeight = (mCheckedListBox.Items.Count * 16) + 7; mCheckedListBox.Height = (PreferredHeight < MaxHeight) ? PreferredHeight : MaxHeight; mCheckedListBox.Width = this.Width; mPopup.Show(mDataGridView.PointToScreen(new Point(e.X, e.Y))); } }
private void pictureBox1_Click(object sender, EventArgs e) { me = (MouseEventArgs)e; pressCanvas = new Point(me.X, me.Y); if (listBox1.SelectedIndex != -1) { popup.Show(this, new Point(Width, 0)); } }
public void Show(Point screenLocation) { if (!_dropDown.Visible) { _host.Control.Location = new Point(0, 0); _dropDown.Size = new Size(_host.Width + 1, _host.Height + 1); _dropDown.Show(screenLocation); } else { _dropDown.Show(screenLocation); } }
// When user right-clicks the cell origin, it clears and fill the CheckedListBox with // columns header text. Then it shows the popup. // In this way the CheckedListBox items are always refreshed to reflect changes occurred in // DataGridView columns (column additions or name changes and so on). void mDataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.Button == MouseButtons.Right && e.RowIndex == -1 && e.ColumnIndex == 0) { mCheckedListBox.Items.Clear(); foreach (DataGridViewColumn c in mDataGridView.Columns) { mCheckedListBox.Items.Add(c.HeaderText, c.Visible); } int PreferredHeight = (mCheckedListBox.Items.Count * 16) + 7; mCheckedListBox.Height = (PreferredHeight < MaxHeight) ? PreferredHeight : MaxHeight; mCheckedListBox.Width = this.Width; mPopup.Show(mDataGridView.PointToScreen(new System.Drawing.Point(e.X, e.Y))); } }
private void button1_Click(object sender, EventArgs e) { DataGridView DropDownGrid = new DataGridView(); DropDownGrid.DataSource = bindingSource1; Button btn = new Button(); this.Controls.Add(DropDownGrid); //if (m_host is null) //{ // m_host = new ToolStripControlHost(btn); //} //m_host.Width = btn.Width; ////m_host.Height = DropDownGrid.Height; //m_dropDownStrip.Items.Add(m_host); //m_dropDownStrip.Show(); if (m_host is null) { m_host = new ToolStripControlHost(DropDownGrid); } m_host.Width = DropDownGrid.Width; //m_host.Height = DropDownGrid.Height; m_dropDownStrip.Items.Add(m_host); //m_dropDownStrip.Left = Me.PointToScreen(New Point With {.X = 0, .Y = Height}).X //m_dropDownStrip.Top = Me.PointToScreen(New Point With {.X = 0, .Y = Height}).Y //'m_dropDownStrip.Size = m_host.Size //'DropDownGrid.Invalidate() //'DropDownGrid.AutoGenerateColumns = True m_dropDownStrip.Show(); //'DropDownGrid.DataSource.ResetBindings(False) //DropDownGrid.Invalidate(); //DropDownGrid.Focus(); }
protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) { ToolStripDropDown t = e.ToolStrip as ToolStripDropDown; if (t != null) { System.Drawing.Pen p; p = new System.Drawing.Pen(Color.FromArgb(127, 127, 127)); e.Graphics.DrawRectangle(p, 0, 0, t.Width - 1, t.Height - 1); p.Dispose(); if (t.OwnerItem != null) { if (t.OwnerItem.OwnerItem == null) { p = new System.Drawing.Pen(Color.FromArgb(31, 31, 31)); e.Graphics.DrawLine(p, 1, 0, t.OwnerItem.Width - 2, 0); p.Dispose(); } else { t.Show(new Point(4, 5)); } } } }
public void ShowDropDown() { //this.Focus(); if (this.dropDown != null) { if (this.bsDGV.DataSource != null) { this.bsDGV.RemoveFilter(); //this.dropTxtSch.Text = ""; this.dropDGVhost.AutoSize = this.dropAutoSize; this.dropDGVhost.Size = new Size(base.DropDownWidth - 2, base.DropDownHeight); this.dropDown.Show(this, 0, base.Height); if (base.PointToScreen(new Point(0, 0)).Y > this.dropDown.Top) { dropDown.Show(this, 0, -this.dropDown.Height); } dropTxtSch.Visible = false; if (dropTxtSch.Visible) { this.dropTxtSch.Focus(); } //dropTxtSch.Select(this.dropTxtSch.TextLength, 0); //bsDGV.Filter = GetSouceFilter(Text); //dropDGV.Refresh(); } } }
void header_FilterButtonClicked(object sender, ColumnFilterClickedEventArg e) { // open a popup on the bottom-left corner of the // filter button // here's we add a simple hello world textbox, but you should add your filter control TextBox innerCtrl = new TextBox(); innerCtrl.Text = "Hello World !"; innerCtrl.Size = new System.Drawing.Size(100, 30); var popup = new ToolStripDropDown(); popup.AutoSize = false; popup.Margin = Padding.Empty; popup.Padding = Padding.Empty; ToolStripControlHost host = new ToolStripControlHost(innerCtrl); host.Margin = Padding.Empty; host.Padding = Padding.Empty; host.AutoSize = false; host.Size = innerCtrl.Size; popup.Size = innerCtrl.Size; popup.Items.Add(host); // show the popup popup.Show(this, e.ButtonRectangle.X, e.ButtonRectangle.Bottom); }
protected override void ButtonPressed() { if (this.PopupControl != null) { if ((this.mPopup == null ? true : !this.mPopup.Visible)) { base.FocusLocked = true; this.mPopup = new ToolStripDropDown() { AutoSize = true, Padding = new Padding(1, 0, 1, 0) }; ToolStripControlHost toolStripControlHost = new ToolStripControlHost(this.PopupControl); this.mPopup.Items.Add(toolStripControlHost); ToolStripDropDown toolStripDropDown = this.mPopup; PropertyGrid propertyGrid = this.mGrid; int num = this.mPopupX; int bottom = this.mButton.Bottom; Point autoScrollPosition = this.mGrid.AutoScrollPosition; toolStripDropDown.Show(propertyGrid, num, bottom + autoScrollPosition.Y); this.mPopup.Closed += new ToolStripDropDownClosedEventHandler(this.mPopup_Closed); this.PopupControl.Focus(); this.onPopup(); } } }
// When user right-clicks the cell origin, it clears and fill the CheckedListBox with // columns header text. Then it shows the popup. // In this way the CheckedListBox items are always refreshed to reflect changes occurred in // DataGridView columns (column additions or name changes and so on). void DataGridViewMouseUp(object sender, MouseEventArgs e) { DataGridView.HitTestInfo hti = _dataGridView.HitTest(e.X, e.Y); if (e.Button == MouseButtons.Right && hti.Type == DataGridViewHitTestType.ColumnHeader) { int textWidth = 0; _checkedListBox.Items.Clear(); foreach (DataGridViewColumn c in _dataGridView.Columns) { if (c.HeaderText.Length == 0) // FxCop: CA1820 { _checkedListBox.Items.Add("(Dummy Column)", c.Visible); } else { _checkedListBox.Items.Add(c.HeaderText, c.Visible); } Size itemWidth = TextRenderer.MeasureText(c.HeaderText, _checkedListBox.Font); textWidth = (itemWidth.Width > textWidth) ? itemWidth.Width : textWidth; } int preferredHeight = (_checkedListBox.Items.Count * 16) + 7; _checkedListBox.Height = (preferredHeight < MaxHeight) ? preferredHeight : MaxHeight; _checkedListBox.Width = textWidth + 20; //Width; _popUp.Show(_dataGridView.PointToScreen(new Point(e.X, e.Y))); } }
void fontSizeButton_Click(object sender, EventArgs e) { if (_isTouch) { fontSizeListbox.Font = bigFont; } else { fontSizeListbox.Font = normalFont; } _isTouch = false; if (fontSizeDropDown.Visible) { fontSizeDropDown.Close(); } else { var control = sender as Control; fontSizeDropDown.Tag = control; int selectedIndex = fontSizeListbox.SelectedIndex; fontSizeListbox.SelectedIndex = -1; fontSizeListbox.SelectedIndex = selectedIndex; fontSizeDropDown.Show(control, new Point(0, control.Height)); } }
private void MainPB_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { dropDown.Show(MainPB, e.Location); } }
private void SelectModel(object sender, EventArgs e) { // We want to pop up a small drop-down window with a // property grid that can be used to set all of the properties // in the ModelViewSettings object. This is a handy non-model // way to change the selected model var dropDownCtrl = new PropertyGrid(); dropDownCtrl.SelectedObject = Object; dropDownCtrl.ToolbarVisible = false; dropDownCtrl.HelpVisible = false; var toolDrop = new ToolStripDropDown(); var toolHost = new ToolStripControlHost(dropDownCtrl); toolHost.Margin = new Padding(0); toolDrop.Padding = new Padding(0); toolDrop.Items.Add(toolHost); // we don't have a way to know the ideal height of the drop down ctrl... just make a guess based on the text height toolHost.AutoSize = false; toolHost.Size = new Size(512, 8 * dropDownCtrl.Font.Height); toolDrop.Show(this, PointToClient(MousePosition)); }
void treeGridViewDifference_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 5 && e.RowIndex != -1) { DataGridViewDisableButtonCell cell = treeGridViewDifference.Rows[e.RowIndex].Cells[5] as DataGridViewDisableButtonCell; if (cell.Enabled) { ToolStripDropDown popup = new ToolStripDropDown(); Difference diff = treeGridViewDifference.Rows[e.RowIndex].Tag as Difference; Point location = new Point(treeGridViewDifference.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Left, treeGridViewDifference.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Bottom); popup.Margin = Padding.Empty; popup.Padding = Padding.Empty; ToolStripControlHost host = new ToolStripControlHost(new WebBrowser() { DocumentText = diff.HtmlDiff, Width = cell.ContentBounds.Width * 2 }); host.Margin = Padding.Empty; host.Padding = Padding.Empty; host.AutoSize = false; host.Size = host.Control.Size; popup.Size = host.Size; popup.DropShadowEnabled = true; popup.Items.Add(host); popup.Show(treeGridViewDifference.PointToScreen(location)); } } }
protected override void InitLayout() { base.InitLayout(); System.Drawing.Point c = EditingControlDataGridView.CurrentCellAddress; string formattedValue = EditingControlDataGridView[c.X, c.Y].FormattedValue.ToString(); popupCtrl = getPopupCtrl(EditingControlDataGridView.CurrentCell); popupValue = popupCtrl as IPopupGridControl; System.Diagnostics.Debug.Assert(popupValue != null); tbh = new ToolStripControlHost(popupCtrl, "popupCtrl"); tbh.Padding = new Padding(0); tbh.AutoSize = true; tsdd = new ToolStripDropDown(); popupValue.EditingControl = this; forwardFocus = true; tsdd.AutoSize = true; tsdd.Items.Add(tbh); tsdd.Padding = new Padding(0); tsdd.Closing += new ToolStripDropDownClosingEventHandler(tsdd_Closing); tsdd.Show(EditingControlDataGridView, EditingControlDataGridView.GetCellDisplayRectangle(c.X, c.Y, true).Location); }
/* * protected internal override void Paint(Graphics gr) * { * if (MouseIsOver && m_Grid.ColumnResizeAllowed && m_Grid.m_RepositioningColumn==null) * using(var br = new LinearGradientBrush(Region, Color.Blue, Color.White, LinearGradientMode.ForwardDiagonal)) * { * gr.FillRectangle(br, Region); * } * } */ protected internal override void OnMouseClick(MouseEventArgs e) { // Right click on the right edge of a column - open the column picker if (e.Button == MouseButtons.Right && m_Grid.Columns.Any() && m_Grid.ColumnHidingAllowed) { var longestText = new string('W', m_Grid.Columns.Max(c => c.Title.Length)); var textSize = TextRenderer.MeasureText(longestText, m_Grid.Font); int preferredHeight = (m_Grid.Columns.Count * textSize.Height) + 7; var checkedListBox = new CheckedListBox() { CheckOnClick = true, Height = (preferredHeight < 350) ? preferredHeight : 350, Width = Math.Min(textSize.Width, m_Grid.Width), }; checkedListBox.ItemCheck += (sender, ea) => { var column = m_Grid.Columns.FirstOrDefault(c => c.Title.Equals(checkedListBox.Items[ea.Index].ToString())); if (column == null) { return; } if (m_Grid.Columns.Count(c => c.Visible) > 1 || ea.NewValue == CheckState.Checked) { column.Visible = ea.NewValue == CheckState.Checked; } else { ea.NewValue = ea.CurrentValue; } }; foreach (var c in m_Grid.Columns) { checkedListBox.Items.Add(c.Title, c.Visible); } var controlHost = new ToolStripControlHost(checkedListBox) { Padding = Padding.Empty, Margin = Padding.Empty, AutoSize = false }; // The following permits handling of custom actions such as applying themes // to the newly created control: m_Grid.Controls.Add(checkedListBox); var popup = new ToolStripDropDown() { Padding = Padding.Empty }; popup.Items.Add(controlHost); popup.Disposed += (sender, args) => m_Grid.Controls.Remove(checkedListBox); // This removes checkedListBox from m_Grid.Controls popup.Show(m_Grid.PointToScreen(e.Location)); } base.OnMouseClick(e); }
private void ShowDropDown() { if (ThisDropDown != null) { TreeViewHost.Size = new Size(DropDownWidth - 2, DropDownHeight); ThisDropDown.Show(this, 0, this.Height + 1); } }
private void showDropDown(int count) { listBox.ItemHeight = this.Height; listBox.Font = this.Font; controlHost.Width = this.Width; controlHost.Height = calcHeightSimple(count); dropDown.Show(this, -2, this.Height - 3); }
private void ShowDropDown() { if (dropDown != null) { treeViewHost.Size = new System.Drawing.Size(DropDownWidth - 2, DropDownHeight); dropDown.Show(this, 0, this.Height); } }
public void LoadChildControl( ) { treeViewHost.Visible = true; treeViewHost.Width = DropDownWidth; treeViewHost.Height = DropDownHeight; (( Control )childControl).Width = DropDownWidth; dropDown.Show(this, 0, this.Height); }
private void ShowDropDown() { if (dropDown != null) { treeViewHost.Width = DropDownWidth; treeViewHost.Height = DropDownHeight; dropDown.Show(this, 0, this.Height); } }
// When user right-clicks the cell origin, it clears and fill the CheckedListBox with // columns header text. Then it shows the popup. // In this way the CheckedListBox items are always refreshed to reflect changes occurred in // DataGridView columns (column additions or name changes and so on). void mDataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { //if (e.Button == MouseButtons.Right && e.RowIndex == -1 && e.ColumnIndex == -1) if (e.Button == MouseButtons.Right && e.ColumnIndex == -1) { //ResetColumn_list(); ColumnItems_Load(); mPopup.Show(mDataGridView.PointToScreen(new Point(e.X, e.Y + mDataGridView.ColumnHeadersHeight))); } }
public virtual void ShowDropDown() { if (!m_droppedDown) { m_dropDown.Show(this, 0, this.Height); m_droppedDown = true; m_checkListBox.Focus(); m_sShowTime = DateTime.Now; } }
private void mgrid_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.Button == MouseButtons.Right) { int PreferredHeight = (mCheckedListBox.Items.Count * 16) + 7; mCheckedListBox.Height = (PreferredHeight < MaxHeight) ? PreferredHeight : MaxHeight; mCheckedListBox.Width = this.Width; mPopup.Show(mgrid.Parent.PointToScreen(new Point(e.X, e.Y))); } }
public Form1() { ToolStripDropDown customToolTip = new ToolStripDropDown(); customToolTip.Items.Add(new CustomPopupControl("Hello", "world")); MouseMove += (o, e) => { Point location = e.Location; location.Offset(0, 16); customToolTip.Show(this, location); }; }
private void ShowDropDown() { if (dropDown != null) { TextBox.Text = ""; textBoxHost.Width = 200; //dataGridViewHost.AutoSize = m_blPopupAutoSize; dataGridViewHost.Size = new Size(DropDownWidth - 2, DropDownHeight + 200); dropDown.Show(this, 0, this.Height); } }
private void BtnML_MouseMove(object sender, MouseEventArgs e) { ToolStripDropDown customToolTip = new ToolStripDropDown(); customToolTip.Items.Add(new CustomPopupControl("Seleccione planta", "world")); Point location = e.Location; location.Offset(10, 10); customToolTip.Show(this, location); }
/// <summary> /// 显示DataView /// </summary> private void ShowDataView() { //CmbBox.Text = this.Text.Substring(0, this.Text.Length - 1); //this.Text = ""; dropDown.Refresh(); SetDataGridView(); dropDown.Show(this, CalculatePoz()); CmbBox.Text = CmbBox.Text.Trim(); CmbBox.Focus(); CmbBox.SelectionStart = CmbBox.Text.Length; }
private void ShowDropDown() { var rect = RectangleToScreen(ClientRectangle); var location = new Point(rect.X, rect.Y + Height); _dropDownControl.Size = new Size(rect.Width, _checkedListBox.Items.Count * _checkedListBox.ItemHeight + ScreenHelpers.ScaleByCurrentDPI(5)); _dropDownControl.Show(location); _dropDownClosing = true; _dropDownControl.Focus(); }