/// <summary> /// mouse Right-click menu /// </summary> /// <param name="e"></param> protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); // 현재 클릭한 GridItem 가져오기 UIElement element = this.DisplayLayout.UIElement.ElementFromPoint(new Point(e.X, e.Y)); object gridItem = element.GetContext(); if (e.Button == MouseButtons.Right) { // 만약 현재 클릭한 GridItem이 UltraGridCell인 경우 if (gridItem is UltraGridColumn) { UltraGridCell activeCell = (UltraGridCell)element.GetContext(typeof(UltraGridCell)); this.ActiveRow = null; this.ActiveCell = null; activeCell.Activate(); } // 1. 컨텍스트 메뉴 구성(생성) ContextMenuStrip strip = this.CreateContextMenu(element); // 2. 컨텍스트 메뉴 사용 가능/불가능 처리 this.AdjustContextMenuItems(strip, element); strip.Show(this, new Point(e.X, e.Y)); } }
private void frmContent_Shown(object sender, EventArgs e) { // Autosize grid columns. this.ultraGrid1.DisplayLayout.PerformAutoResizeColumns(false, PerformAutoSizeType.VisibleRows, AutoResizeColumnWidthOptions.All); if (this.ultraGrid1.Rows.Count > 0) { // Activate the first row. this.ultraGrid1.Rows[0].Activate(); if (this.ultraGrid1.ActiveRow != null) { if (!this.ultraGrid1.ActiveRow.IsGroupByRow) { // If not a group by row then activate the first cell. UltraGridCell cell = this.ultraGrid1.ActiveRow.Cells[this.ultraGrid1.DisplayLayout.Bands[0].GetFirstVisibleCol(this.ultraGrid1.DisplayLayout.ColScrollRegions[0], false)]; if (cell != null) { cell.Activate(); if (this.contentType == Enums.ContentType.Customers) { // If this is the Customers ContentType then we actually want the next cell active. this.ultraGrid1.PerformAction(UltraGridAction.NextCell); } } } else { // If this is a group by row then expand all the rows. this.ultraGrid1.Rows.ExpandAll(false); if (this.contentType == Enums.ContentType.OrderDetails) { // Activate the first row under the first expanded group by row. this.ultraGrid1.Rows[0].ChildBands[0].Rows[0].Activate(); UltraGridCell cell = this.ultraGrid1.ActiveRow.Cells[this.ultraGrid1.DisplayLayout.Bands[0].GetFirstVisibleCol(this.ultraGrid1.DisplayLayout.ColScrollRegions[0], false)]; if (cell != null) { // Activate the first cell. cell.Activate(); } } } } } // Give the charts sample data this.AssignChartData(); // The pie chart has the ability to break apart specific slices to draw attention to that slice. // this.ultraChart2.PieChart.BreakSlice(1, true); // this.piecha.PieChart.BreakSlice(1, true); }
/// <summary> /// mouse Right-click menu /// </summary> /// <param name="e"></param> protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (e.Button == MouseButtons.Right) { // 현재 클릭한 GridItem 가져오기 UIElement element = this.DisplayLayout.UIElement.ElementFromPoint(new Point(e.X, e.Y)); object selectedItem = element.GetContext(); this.ActiveCell = null; this.Selected.Rows.Clear(); this.Selected.Cells.Clear(); this.Selected.Columns.Clear(); if (selectedItem is ColumnHeader) { ColumnHeader columnHeader = (ColumnHeader)element.GetContext(typeof(ColumnHeader)); columnHeader.Selected = true; foreach (var row in this.Rows) { row.Cells[columnHeader.Column].Activate(); this.ActiveCell.Selected = true; } } if (selectedItem is UltraGridColumn) { UltraGridCell activeCell = (UltraGridCell)element.GetContext(typeof(UltraGridCell)); activeCell.Activate(); } // 1. 컨텍스트 메뉴 구성(생성) ContextMenuStrip strip = this.CreateContextMenu(element); // 2. 컨텍스트 메뉴 사용 가능/불가능 처리 this.AdjustContextMenuItems(strip, element); strip.Show(this, new Point(e.X, e.Y)); } }