private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var clickedElement = e.OriginalSource as FrameworkElement; if (clickedElement != null) { var headerCell = clickedElement.ParentOfType <GridViewHeaderCell>(); if (headerCell != null) { foreach (var item in this.clubsGrid.Items) { var cellInfo = new GridViewCellInfo(item, headerCell.Column, this.clubsGrid); if (!this.clubsGrid.SelectedCells.Contains(cellInfo)) { this.clubsGrid.SelectedCells.Add(cellInfo); } else { this.clubsGrid.SelectedCells.Remove(cellInfo); } } } } }
void radGridView1_PrintCellPaint(object sender, PrintCellPaintEventArgs e) { if (e.Row.Index >= 0) { GridViewCellInfo cell = this.radGridView1.Rows[e.Row.Index].Cells[e.Column.Index]; if (cell.Style.BorderTopColor == Color.Transparent) { e.Graphics.DrawLine( Pens.White, new Point(e.CellRect.Left + 1, e.CellRect.Top), new Point(e.CellRect.Right - 1, e.CellRect.Top)); } if (cell.Style.BorderLeftColor == Color.Transparent) { e.Graphics.DrawLine( Pens.White, new Point(e.CellRect.Left, e.CellRect.Top), new Point(e.CellRect.Left - 1, e.CellRect.Bottom)); } if (cell.Style.ForeColor == Color.Transparent) { Rectangle r = new Rectangle(e.CellRect.X + 1, e.CellRect.Y + 1, e.CellRect.Width - 2, e.CellRect.Height - 2); e.Graphics.FillRectangle(Brushes.White, r); } } }
private void releaseSession_ToolStripButton_Click(object sender, EventArgs e) { _selectedSessionCell = SelectedSession; var sessionId = _selectedSessionCell.Value.ToString(); if (!GlobalSettings.IsDistributedSystem) { if (sessionData_GridView.SelectedRows[0].Cells[12].Value.ToString() != Environment.MachineName.ToUpper()) { var message = MessageBox.Show($"You are trying to release a session which was run on client machine -' { sessionData_GridView.SelectedRows[0].Cells[12].Value} ' . This will not close the Virtual worker console on that client. Do you want to continue?", "Release Session", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (message == System.Windows.Forms.DialogResult.No) { return; } } } string msg = "This will abort the session (if it is currently running) and release all machines and other assets used in this test. Are you sure you want to release this Session?"; var result = MessageBox.Show(msg, "Reset Session", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == System.Windows.Forms.DialogResult.No) { return; } if (!string.IsNullOrEmpty(sessionId)) { _sessionResetting = sessionId; if (STFDispatcherManager.Dispatcher == null && STFDispatcherManager.ConnectToDispatcher() == false) { //The user canceled the connect dialog return; } // For STE, require that shutdown requester be authorized SessionResetManager resetManager = new SessionResetManager(); if (GlobalSettings.IsDistributedSystem) { if (!resetManager.IsAuthorized(sessionId)) { return; } } using (SessionShutdownForm form = new SessionShutdownForm(sessionId)) { if (form.ShowDialog(this) == DialogResult.OK) { resetManager.LogSessionReset(sessionId); SetControls(true); SessionClient.Instance.ClearSessionRequestReceived += controller_SessionResetComplete; SessionClient.Instance.SetUserCredential(UserManager.CurrentUser); SessionClient.Instance.Close(sessionId, form.ShutdownOptions); } } statusLabel.Text = "Releasing session {0} and cleaning up associated virtual machines and resources...".FormatWith(sessionId); } }
private void MergeHorizontally(RadGridView radGridView, int startColumnIndex, int endColumnIndex) { foreach (GridViewRowInfo item in radGridView.Rows) { for (int i = startColumnIndex; i < endColumnIndex; i++) { GridViewCellInfo firstCell = item.Cells[i]; GridViewCellInfo secondCell = item.Cells[i + 1]; string firstCellText = (firstCell != null && firstCell.Value != null ? firstCell.Value.ToString() : string.Empty); string secondCellText = (secondCell != null && secondCell.Value != null ? secondCell.Value.ToString() : string.Empty); setCellBorders(firstCell, Color.FromArgb(209, 225, 245)); setCellBorders(secondCell, Color.FromArgb(209, 225, 245)); if (firstCellText == secondCellText) { firstCell.Style.BorderRightColor = Color.Transparent; secondCell.Style.BorderLeftColor = Color.Transparent; secondCell.Style.ForeColor = Color.Transparent; } else { secondCell.Style.ForeColor = Color.Black; } } } }
private void StyleCell(GridViewCellInfo cell) { cell.Style.Font = this.BaseFont; cell.Style.CustomizeFill = true; cell.Style.GradientStyle = GradientStyles.Solid; cell.Style.BackColor = Color.FromArgb(228, 236, 247); }
private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var clickedElement = e.OriginalSource as FrameworkElement; if (clickedElement != null) { var headerCell = clickedElement.ParentOfType<GridViewHeaderCell>(); if (headerCell != null) { foreach (var item in this.clubsGrid.Items) { var cellInfo = new GridViewCellInfo(item, headerCell.Column, this.clubsGrid); if (!this.clubsGrid.SelectedCells.Contains(cellInfo)) { this.clubsGrid.SelectedCells.Add(cellInfo); } else { this.clubsGrid.SelectedCells.Remove(cellInfo); } } } } }
private void StyleHeaderCell(GridViewCellInfo cell) { cell.Style.Font = this.BaseFont; cell.Style.CustomizeFill = true; cell.Style.GradientStyle = GradientStyles.Solid; cell.Style.BackColor = Color.FromArgb(162, 215, 255); }
private void setCellBorders(GridViewCellInfo cell, Color color) { cell.Style.CustomizeBorder = true; cell.Style.BorderBoxStyle = Telerik.WinControls.BorderBoxStyle.FourBorders; cell.Style.BorderLeftColor = color; cell.Style.BorderRightColor = color; cell.Style.BorderBottomColor = color; if (cell.Style.BorderTopColor != Color.Transparent) { cell.Style.BorderTopColor = color; } }
public CellFormattingEventArgs( int gridRowIndex, int gridColumnIndex, Type gridRowInfoType, GridViewCellInfo gridViewCellInfo, object cellSelection, ISpreadExportCellStyleInfo cellStyleInfo) { this.gridRowIndex = gridRowIndex; this.gridColumnIndex = gridColumnIndex; this.gridRowInfoType = gridRowInfoType; this.gridViewCellInfo = gridViewCellInfo; this.cellSelection = cellSelection; this.cellStyleInfo = cellStyleInfo; }
private void CheckBox_Unchecked(object sender, RoutedEventArgs e) { var headerCell = (sender as CheckBox).ParentOfType<GridViewHeaderCell>(); if (headerCell != null) { foreach (var item in this.clubsGrid2.Items) { var cellInfo = new GridViewCellInfo(item, headerCell.Column, this.clubsGrid2); if (this.clubsGrid2.SelectedCells.Contains(cellInfo)) { this.clubsGrid2.SelectedCells.Remove(cellInfo); } } } }
private void CheckBox_Unchecked(object sender, RoutedEventArgs e) { var headerCell = (sender as CheckBox).ParentOfType <GridViewHeaderCell>(); if (headerCell != null) { foreach (var item in this.clubsGrid2.Items) { var cellInfo = new GridViewCellInfo(item, headerCell.Column, this.clubsGrid2); if (this.clubsGrid2.SelectedCells.Contains(cellInfo)) { this.clubsGrid2.SelectedCells.Remove(cellInfo); } } } }
private void removeAssociation_ToolStripMenuItem_Click(object sender, EventArgs e) { GridViewRowInfo row = printQueue_GridView.SelectedRows.FirstOrDefault(); if (row != null) { GridViewCellInfo otherCell = row.Cells[QueueColumns.Name]; RemotePrintQueue queue = _controller.Context.RemotePrintQueues.Where(x => x.Name == otherCell.Value.ToString()).FirstOrDefault(); _controller.Context.RemotePrintQueues.Remove(queue); _controller.Context.SaveChanges(); row.Delete(); printQueue_GridView.Refresh(); } }
private void MergeVertically(RadGridView radGridView, int[] columnIndexes) { GridViewRowInfo Prev = null; foreach (GridViewRowInfo item in radGridView.Rows) { if (Prev != null) { string firstCellText = string.Empty; string secondCellText = string.Empty; foreach (int i in columnIndexes) { GridViewCellInfo firstCell = Prev.Cells[i]; GridViewCellInfo secondCell = item.Cells[i]; firstCellText = (firstCell != null && firstCell.Value != null ? firstCell.Value.ToString() : string.Empty); secondCellText = (secondCell != null && secondCell.Value != null ? secondCell.Value.ToString() : string.Empty); setCellBorders(firstCell, Color.FromArgb(209, 225, 245)); setCellBorders(secondCell, Color.FromArgb(209, 225, 245)); if (firstCellText == secondCellText) { firstCell.Style.BorderBottomColor = Color.Transparent; secondCell.Style.BorderTopColor = Color.Transparent; secondCell.Style.ForeColor = Color.Transparent; } else { secondCell.Style.ForeColor = Color.Black; Prev = item; break; } } } else { Prev = item; } } }
// http://stackoverflow.com/questions/33895403/wpf-radgridview-loop-through-rows-cant-get-all-rows/33916970#33916970 //The reason why didn't work. But this method can be reused in another thing. //private List<object> ReturnListFounds(string text) //{ // List<object> result = new List<object>(); // int index = 0; // foreach (var item in this.Items) // { // if (item == null) // continue; // GridViewRow row = this.ItemContainerGenerator.ContainerFromItem(item) as GridViewRow; // if (row == null) // { // row = this.ItemContainerGenerator.ContainerFromIndex(index) as GridViewRow; // if (row == null) // { // index++; // continue; // } // } // foreach (GridViewCell cell in row.Cells) // { // if (cell != null && cell.Value != null) // { // string str = cell.Value.ToString(); // if (str.Equals(text, StringComparison.InvariantCultureIgnoreCase) || str.ToLower().Contains(text.ToLower())) // { // result.Add(row.Item); // break; // } // } // } // index++; // } // result = new List<object>(result.Distinct()); // return result; //} #endregion private List <object> ReturnListFounds(string text) { List <object> result = new List <object>(); for (int l = 0; l <= Items.Count; l++) { var cell = new GridViewCellInfo(this.Items[l], this.Columns[0], this); if (cell.Item != null) { var props = cell.Item.GetType().GetProperties(); foreach (var p in props) { if (p == null || cell.Item == null) { continue; } var t = p.GetValue(cell.Item); if (t == null) { continue; } var str = t.ToString(); if (str.Equals(text, StringComparison.InvariantCultureIgnoreCase) || str.ToLower().Contains(text)) { result.Add(cell.Item); } } } } result = new List <object>(result.Distinct()); return(result); }
private void AddInventoryId(GridViewRowInfo rowToUpdate) { GridViewCellInfo targetCell = rowToUpdate.Cells[QueueColumns.InventoryId]; if (SelectedQueue != null) { object valueObject = targetCell.Value; string currentValue = string.Empty; if (valueObject != null) { currentValue = valueObject.ToString(); } using (AssetSelectionForm printerSelectionForm = new AssetSelectionForm(AssetAttributes.Printer, currentValue)) { printerSelectionForm.ShowDialog(this); if (printerSelectionForm.DialogResult == DialogResult.OK) { targetCell.Value = printerSelectionForm.SelectedAssetIds.FirstOrDefault(); printQueue_GridView.Refresh(); } } } }