private void _grid_MouseDown(object sender, MouseEventArgs e) { // Note: this event handler is used for the MouseDown event on all grids//if (items.Count == 1) UltraGrid grid = (UltraGrid)sender; UIElement elementMain = grid.DisplayLayout.UIElement; var elementUnderMouse = elementMain.ElementFromPoint(new Point(e.X, e.Y)); if (elementUnderMouse != null) { UltraGridCell cell = elementUnderMouse.GetContext(typeof(UltraGridCell)) as UltraGridCell; if (cell == null) { m_gridCellClicked = false; HeaderUIElement he = elementUnderMouse.GetAncestor(typeof(HeaderUIElement)) as HeaderUIElement; ColScrollbarUIElement ce = elementUnderMouse.GetAncestor(typeof(ColScrollbarUIElement)) as ColScrollbarUIElement; RowScrollbarUIElement re = elementUnderMouse.GetAncestor(typeof(RowScrollbarUIElement)) as RowScrollbarUIElement; if (he == null && ce == null && re == null) { grid.Selected.Rows.Clear(); grid.ActiveRow = null; } } } }
public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { // Custom draw borders around the column headers. HeaderUIElement headerUiElement = drawParams.Element as HeaderUIElement; if (headerUiElement != null && drawPhase == DrawPhase.BeforeDrawBorders) { drawParams.DrawBorders(headerUiElement.BorderStyle, Border3DSide.Bottom); return(true); } // Remove the focus rectangle. if (drawPhase == DrawPhase.BeforeDrawFocus) { return(true); } return(false); }
private void aCheckBoxUIElement_ElementClick(Object sender, Infragistics.Win.UIElementEventArgs e) { // Get the CheckBoxUIElement that was clicked CheckBoxUIElement aCheckBoxUIElement = (CheckBoxUIElement)e.Element; // Get the Header associated with this particular element Infragistics.Win.UltraWinGrid.ColumnHeader aColumnHeader = (Infragistics.Win.UltraWinGrid.ColumnHeader)aCheckBoxUIElement.GetAncestor(typeof(HeaderUIElement)).GetContext(typeof(Infragistics.Win.UltraWinGrid.ColumnHeader)); // Set the Tag on the Header to the new CheckState aColumnHeader.Tag = aCheckBoxUIElement.CheckState; // So that we can apply various changes only to the relevant Rows collection that the header belongs to HeaderUIElement aHeaderUIElement = aCheckBoxUIElement.GetAncestor(typeof(HeaderUIElement)) as HeaderUIElement; RowsCollection hRows = aHeaderUIElement.GetContext(typeof(RowsCollection)) as RowsCollection; // Raise an event so the programmer can do something when the CheckState changes if (_CLICKED != null) { _CLICKED(this, new HeaderCheckBoxEventArgs(aColumnHeader, aCheckBoxUIElement.CheckState, hRows)); } }
/// <summary> /// Handles the Click event of the SearchResultGrid control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> private void SearchResultGrid_Click(object sender, EventArgs e) { try { MouseEventArgs e1 = (MouseEventArgs)e; Infragistics.Win.UIElement elementUi; Point mousePoint = new Point(e1.X, e1.Y); // Cast the sender into an UltraGrid // Get the Mouse Point UIElement element = ((UltraGrid)sender).DisplayLayout.UIElement.ElementFromPoint(mousePoint); elementUi = this.SearchResultGrid.DisplayLayout.UIElement.ElementFromPoint(new Point(e1.X, e1.Y)); if (element == null) { return; } // Try to get a Column from the element UltraGridColumn col = elementUi.GetContext(typeof(UltraGridColumn)) as UltraGridColumn; // Gets the Header Element HeaderUIElement headerElement = element.GetAncestor(typeof(HeaderUIElement)) as HeaderUIElement; if (headerElement != null) { this.hitCount++; this.columnIndex = col.Index; if (this.hitCount > 1) { if (this.columnIndex.Equals(2)) { if (this.groupSearchIndicator.Equals(SortIndicator.Ascending)) { if (this.searchSearchIndicator.Equals(SortIndicator.Ascending)) { this.groupSearchIndicator = SortIndicator.Descending; this.searchSearchIndicator = SortIndicator.Ascending; } else { this.groupSearchIndicator = SortIndicator.Descending; this.searchSearchIndicator = SortIndicator.Descending; } } else { if (this.searchSearchIndicator.Equals(SortIndicator.Ascending)) { this.groupSearchIndicator = SortIndicator.Ascending; this.searchSearchIndicator = SortIndicator.Ascending; } else { this.groupSearchIndicator = SortIndicator.Ascending; this.searchSearchIndicator = SortIndicator.Descending; } } } else if (this.columnIndex.Equals(4) || this.columnIndex.Equals(5)) { if (this.groupSearchIndicator.Equals(SortIndicator.Ascending)) { if (this.searchSearchIndicator.Equals(SortIndicator.Ascending)) { this.groupSearchIndicator = SortIndicator.Ascending; this.searchSearchIndicator = SortIndicator.Descending; } else { this.groupSearchIndicator = SortIndicator.Ascending; this.searchSearchIndicator = SortIndicator.Ascending; } } else { if (this.searchSearchIndicator.Equals(SortIndicator.Ascending)) { this.groupSearchIndicator = SortIndicator.Descending; this.searchSearchIndicator = SortIndicator.Descending; } else { this.groupSearchIndicator = SortIndicator.Descending; this.searchSearchIndicator = SortIndicator.Ascending; } } } } if (this.SearchResultGrid.ActiveCell != null) { this.SearchResultGrid.ActiveCell.Selected = false; } } } catch (Exception ex) { ExceptionManager.ManageException(ex, ExceptionManager.ActionType.CloseCurrentForm, this.ParentForm); } }