/// ------------------------------------------------------------------------------------ /// <summary> /// Creates an exact copy of this cell. /// </summary> /// <returns> /// An <see cref="T:System.Object"/> that represents the cloned /// <see cref="T:System.Windows.Forms.DataGridViewCell"></see>. /// </returns> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/> /// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/> /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence"/> /// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/> /// </PermissionSet> /// ------------------------------------------------------------------------------------ public override object Clone() { DataGridViewControlCell dataGridViewCell = base.Clone() as DataGridViewControlCell; Debug.Assert(dataGridViewCell != null); dataGridViewCell.m_Control = m_Control; dataGridViewCell.m_ControlCreateInfo = m_ControlCreateInfo; return(dataGridViewCell); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates the control in column. /// </summary> /// <param name="cell">The cell that will host the control we create.</param> /// ------------------------------------------------------------------------------------ private void CreateHostedControl(DataGridViewControlCell cell) { if (cell.ControlCreateInfo == null || cell.ControlCreateInfo.ViewProxy == null) { return; } IRootSiteGroup group = cell.ControlCreateInfo.Group; Control c = cell.ControlCreateInfo.ViewProxy.CreateView(this); if (c is RootSite) { RootSite rs = c as RootSite; rs.Cache = m_cache; rs.StyleSheet = m_StyleSheet; } if (group != null && c is IRootSiteSlave) { IRootSiteSlave slave = c as IRootSiteSlave; group.AddToSyncGroup(slave); if (cell.ControlCreateInfo.IsScrollingController) { #if __MonoCS__ // TODO-Linux: HACK Check to see if a ScrollingControl has (in error) already been set. // hack to prevent multiple scrollbars controling a group // This isn't needed in Windows as RootSite.cs check to see if it is the Group ScrollingController // Which should mean that if multiple scrolling Control are set only the last one actually contains a scrollbar // However because on mono Creating events aren't exactly the same (shame!) the group property of the RootSite get set before // the second RootSite with the ScrollingControl set, get created meaning when the group is set it IS the scrolling controler! (and hence AutoScroll isn't set to false) // A alternative way of fixing this (and probably better) would be to change the ViewWrapperContructor to only set a single ScrollingControl // (currently BtWrapper set one) and calls it base which also has set one. if (group.ScrollingController != null) { if (group.ScrollingController is ScrollableControl) { (group.ScrollingController as ScrollableControl).AutoScroll = false; } } #endif group.ScrollingController = slave; } } if (c is ISelectableView) { ((ISelectableView)c).BaseInfoBarCaption = m_baseInfoBarCaption; } cell.ControlCreateInfo.Control = c; OnHostedControlCreated(c); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates the control in column. /// </summary> /// <param name="cell">The cell that will host the control we create.</param> /// ------------------------------------------------------------------------------------ private void CreateHostedControl(DataGridViewControlCell cell) { if (cell.ControlCreateInfo == null || (ControlCreator == null && !(cell.ControlCreateInfo.ClientControlInfo is FixedControlCreateInfo))) { return; } IRootSiteGroup group = cell.ControlCreateInfo.Group; Control c; if (cell.ControlCreateInfo.ClientControlInfo is FixedControlCreateInfo) { // We know how to deal with this! c = ((FixedControlCreateInfo)cell.ControlCreateInfo.ClientControlInfo).Control; } else { c = ControlCreator.Create(this, cell.ControlCreateInfo.ClientControlInfo); } if (c is RootSite) { RootSite rs = c as RootSite; rs.Cache = m_cache; rs.StyleSheet = m_StyleSheet; } if (group != null && c is IRootSiteSlave) { IRootSiteSlave slave = c as IRootSiteSlave; group.AddToSyncGroup(slave); if (cell.ControlCreateInfo.IsScrollingController) { group.ScrollingController = slave; } } if (c is ISelectableView) { ((ISelectableView)c).BaseInfoBarCaption = m_baseInfoBarCaption; } cell.ControlCreateInfo.Control = c; OnHostedControlCreated(c); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes the control. This consists of calling MakeRoot and creating the handle /// of the control. /// </summary> /// <param name="cell">The cell.</param> /// ------------------------------------------------------------------------------------ private void InitControl(DataGridViewControlCell cell) { if (cell.ControlCreateInfo == null) { return; } Control c = cell.ControlCreateInfo.Control; if (c is SimpleRootSite) { SimpleRootSite rootSite = c as SimpleRootSite; rootSite.AllowLayout = false; rootSite.MakeRoot(); } cell.Control = c; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Raises the <see cref="E:System.Windows.Forms.DataGridView.RowHeightChanged"></see> /// event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.DataGridViewRowEventArgs"></see> /// that contains the event data.</param> /// <exception cref="T:System.ArgumentException">The row indicated by the /// <see cref="P:System.Windows.Forms.DataGridViewRowEventArgs.Row"></see> property of /// e does not belong to this <see cref="T:System.Windows.Forms.DataGridView"></see> /// control.</exception> /// ------------------------------------------------------------------------------------ protected override void OnRowHeightChanged(DataGridViewRowEventArgs e) { if (e.Row.Height == DataGridViewControlColumn.kMinimumValue && m_fFullyInitialized) { // user dragged the divider all the way to the top, so we hide the row e.Row.Visible = false; } base.OnRowHeightChanged(e); if (!m_fResizeInProgress) { AdjustRowWeight(e.Row as DataGridViewControlRow); } ResizeRows(false); // Adjust the positions of the views in rows following the row that changed height int iLastRow = LastVisibleRow; for (int iRow = e.Row.Index + 1; iRow <= iLastRow; iRow++) { DataGridViewRow row = Rows[iRow]; if (!row.Visible) { continue; } for (int iColumn = 0; iColumn < ColumnCount; iColumn++) { if (!Columns[iColumn].Visible) { continue; } DataGridViewControlCell cell = row.Cells[iColumn] as DataGridViewControlCell; if (cell.Control != null) { cell.Control.Location = cell.CellContentDisplayRectangle.Location; } } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the control at the specified location. /// </summary> /// <param name="group">The group.</param> /// <param name="column">The column index.</param> /// <param name="row">The row index.</param> /// <param name="controlProxy">Client-provided information necessary to create the /// control.</param> /// <param name="fDefaultFocusControl"><c>true</c> if this control will get focus /// if this split grid receives focus.</param> /// <param name="fScrollingContainer"><c>true</c> if this control should control /// scrolling (and display a scroll bar)</param> /// ------------------------------------------------------------------------------------ public void AddControl(IRootSiteGroup group, int row, int column, ViewProxy controlProxy, bool fDefaultFocusControl, bool fScrollingContainer) { CheckBounds(row, column); if (fDefaultFocusControl) { m_CellToActivate = new Point(column, row); } if (row >= m_grid.RowCount) { m_grid.RowCount = row + 1; m_grid.Rows[m_grid.RowCount - 1].Visible = false; m_grid.Rows[m_grid.RowCount - 1].MinimumHeight = DataGridViewControlColumn.kMinimumValue; } DataGridViewControlCell cell = m_grid.Rows[row].Cells[column] as DataGridViewControlCell; Debug.Assert(cell != null); cell.ControlCreateInfo = new ControlCreateInfo(group ?? m_defaultGroup, controlProxy, fScrollingContainer); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes the control. This consists of calling MakeRoot and creating the handle /// of the control. /// </summary> /// <param name="cell">The cell.</param> /// ------------------------------------------------------------------------------------ private void InitControl(DataGridViewControlCell cell) { if (cell.ControlCreateInfo == null) return; Control c = cell.ControlCreateInfo.Control; if (c is SimpleRootSite) { SimpleRootSite rootSite = c as SimpleRootSite; rootSite.AllowLayout = false; rootSite.MakeRoot(); } cell.Control = c; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates the control in column. /// </summary> /// <param name="cell">The cell that will host the control we create.</param> /// ------------------------------------------------------------------------------------ private void CreateHostedControl(DataGridViewControlCell cell) { if (cell.ControlCreateInfo == null || cell.ControlCreateInfo.ViewProxy == null) return; IRootSiteGroup group = cell.ControlCreateInfo.Group; Control c = cell.ControlCreateInfo.ViewProxy.CreateView(this); if (c is RootSite) { RootSite rs = c as RootSite; rs.Cache = m_cache; rs.StyleSheet = m_StyleSheet; } if (group != null && c is IRootSiteSlave) { IRootSiteSlave slave = c as IRootSiteSlave; group.AddToSyncGroup(slave); if (cell.ControlCreateInfo.IsScrollingController) { #if __MonoCS__ // TODO-Linux: HACK Check to see if a ScrollingControl has (in error) already been set. // hack to prevent multiple scrollbars controling a group // This isn't needed in Windows as RootSite.cs check to see if it is the Group ScrollingController // Which should mean that if multiple scrolling Control are set only the last one actually contains a scrollbar // However because on mono Creating events aren't exactly the same (shame!) the group property of the RootSite get set before // the second RootSite with the ScrollingControl set, get created meaning when the group is set it IS the scrolling controler! (and hence AutoScroll isn't set to false) // A alternative way of fixing this (and probably better) would be to change the ViewWrapperContructor to only set a single ScrollingControl // (currently BtWrapper set one) and calls it base which also has set one. if (group.ScrollingController != null) { if (group.ScrollingController is ScrollableControl) (group.ScrollingController as ScrollableControl).AutoScroll = false; } #endif group.ScrollingController = slave; } } if (c is ISelectableView) ((ISelectableView)c).BaseInfoBarCaption = m_baseInfoBarCaption; cell.ControlCreateInfo.Control = c; OnHostedControlCreated(c); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates the control in column. /// </summary> /// <param name="cell">The cell that will host the control we create.</param> /// ------------------------------------------------------------------------------------ private void CreateHostedControl(DataGridViewControlCell cell) { if (cell.ControlCreateInfo == null || (ControlCreator == null && !(cell.ControlCreateInfo.ClientControlInfo is FixedControlCreateInfo) )) return; IRootSiteGroup group = cell.ControlCreateInfo.Group; Control c; if (cell.ControlCreateInfo.ClientControlInfo is FixedControlCreateInfo) { // We know how to deal with this! c = ((FixedControlCreateInfo)cell.ControlCreateInfo.ClientControlInfo).Control; } else c = ControlCreator.Create(this, cell.ControlCreateInfo.ClientControlInfo); if (c is RootSite) { RootSite rs = c as RootSite; rs.Cache = m_cache; rs.StyleSheet = m_StyleSheet; } if (group != null && c is IRootSiteSlave) { IRootSiteSlave slave = c as IRootSiteSlave; group.AddToSyncGroup(slave); if (cell.ControlCreateInfo.IsScrollingController) group.ScrollingController = slave; } if (c is ISelectableView) ((ISelectableView)c).BaseInfoBarCaption = m_baseInfoBarCaption; cell.ControlCreateInfo.Control = c; OnHostedControlCreated(c); }