private float MeasureCell( GridRowElement row, GridViewColumn column, GridColumnGroupCellElement cell) { cell.Initialize(column, row); cell.SetContent(); cell.UpdateInfo(); row.SuspendLayout(); row.Children.Add((RadElement)cell); cell.ResetLayout(true); float cellDesiredWidth = this.GetCellDesiredWidth((GridCellElement)cell); row.Children.Remove((RadElement)cell); row.ResumeLayout(false); return(cellDesiredWidth); }
private void BestFitGroupColumn( GridViewGroupColumn column, bool bestFitChildColumns, BestFitColumnMode?mode) { GridTableHeaderRowElement headerRowElement = this.GetHeaderRowElement(); IVirtualizedElementProvider <GridViewColumn> elementProvider = this.tableElement.ColumnScroller.ElementProvider; ColumnGroupRowLayout rowLayout = this.tableElement.ViewElement.RowLayout as ColumnGroupRowLayout; if (rowLayout == null || headerRowElement == null) { return; } GridColumnGroupCellElement element = elementProvider.GetElement((GridViewColumn)column, (object)headerRowElement) as GridColumnGroupCellElement; if (element == null || !element.CanBestFit(column.AutoSizeMode)) { return; } float num = this.MeasureCell((GridRowElement)headerRowElement, (GridViewColumn)column, element); this.Detach(elementProvider, (GridCellElement)element); ColumnGroupsCellArrangeInfo columnData = rowLayout.GetColumnData((GridViewColumn)column); if ((double)columnData.Bounds.Width < (double)num) { rowLayout.StartColumnResize((GridViewColumn)column); rowLayout.ResizeColumn((int)((double)num - (double)columnData.Bounds.Width)); rowLayout.InvalidateLayout(); this.TableElement.ViewElement.InvalidateMeasure(true); this.TableElement.ViewElement.UpdateLayout(); rowLayout.EndColumnResize(); } if (!bestFitChildColumns) { return; } foreach (GridViewColumn dataColumn in this.GetDataColumns(column.Group)) { this.BestFitColumnCore(dataColumn, mode.HasValue ? mode.Value : column.AutoSizeMode); } }
public override void UpdateDropContext( ISupportDrag draggedContext, ISupportDrop dropTarget, Point?location) { GridColumnGroupCellElement groupCellElement = dropTarget as GridColumnGroupCellElement; GridHeaderCellElement headerCellElement = dropTarget as GridHeaderCellElement; GridViewGroupColumn gridViewGroupColumn = groupCellElement != null ? groupCellElement.ColumnInfo as GridViewGroupColumn : (GridViewGroupColumn)null; if (headerCellElement == null || !location.HasValue) { this.orientation = Orientation.Vertical; } else { if (headerCellElement.RowElement == null || headerCellElement.RowElement.TableElement == null) { return; } Rectangle boundingRectangle1 = headerCellElement.ControlBoundingRectangle; Rectangle boundingRectangle2 = headerCellElement.RowElement.TableElement.ViewElement.ControlBoundingRectangle; if (boundingRectangle1.Right > boundingRectangle2.Right) { boundingRectangle1.Width -= boundingRectangle1.Right - boundingRectangle2.Right; } if (boundingRectangle1.X < boundingRectangle2.X) { boundingRectangle1.Width -= boundingRectangle2.X - boundingRectangle1.X; boundingRectangle1.X = boundingRectangle2.X; } if ((RadGridViewDragDropService.GetDropPosition(headerCellElement.PointFromScreen(location.Value), headerCellElement.Size) & RadPosition.Bottom) != RadPosition.None && (gridViewGroupColumn != null && gridViewGroupColumn.Group.Rows.Count == 0 && draggedContext.GetDataContext() is GridViewGroupColumn || gridViewGroupColumn != null && gridViewGroupColumn.Group.Groups.Count == 0 && draggedContext.GetDataContext() is GridViewDataColumn || gridViewGroupColumn == null)) { this.orientation = Orientation.Horizontal; } else { this.orientation = Orientation.Vertical; } } }