Beispiel #1
0
 /// <summary>
 /// Handler for a Column's PropertyChanged event
 /// </summary>
 /// <param name="sender">The object that raised the event</param>
 /// <param name="e">A ColumnEventArgs that contains the event data</param>
 private void column_PropertyChanged(object sender, ColumnEventArgs e)
 {
     this.columnCollection.ColumnModel.OnColumnPropertyChanged(e);
 }
Beispiel #2
0
		/// <summary>
		/// Raises the BeginSort event
		/// </summary>
		/// <param name="e">A ColumnEventArgs that contains the event data</param>
		protected virtual void OnBeginSort(ColumnEventArgs e)
		{
			if (BeginSort != null)
			{
				BeginSort(this, e);
			}
		}
Beispiel #3
0
		/// <summary>
		/// Raises the EndSort event
		/// </summary>
		/// <param name="e">A ColumnEventArgs that contains the event data</param>
		protected virtual void OnEndSort(ColumnEventArgs e)
		{
			if (EndSort != null)
			{
				EndSort(this, e);
			}
		}
Beispiel #4
0
		/// <summary>
		/// Raises the ColumnPropertyChanged event
		/// </summary>
		/// <param name="e">A ColumnEventArgs that contains the event data</param>
		protected internal virtual void OnColumnPropertyChanged(ColumnEventArgs e)
		{
			if (this.CanRaiseEvents)
			{
				Rectangle columnHeaderRect;
					
				if (e.Index != -1)
				{
					columnHeaderRect = this.ColumnHeaderRect(e.Index);
				}
				else
				{
					columnHeaderRect = this.ColumnHeaderRect(e.Column);
				}
			
				switch (e.EventType)
				{
					case ColumnEventType.VisibleChanged:
					case ColumnEventType.WidthChanged:
					{
						if (e.EventType == ColumnEventType.VisibleChanged)
						{
							if (e.Column.Visible && e.Index != this.lastSortedColumn)
							{
								e.Column.InternalSortOrder = SortOrder.None;
							}

							if (e.Index == this.FocusedCell.Column && !e.Column.Visible)
							{
								int index = this.ColumnModel.NextVisibleColumn(e.Index);

								if (index == -1)
								{
									index = this.ColumnModel.PreviousVisibleColumn(e.Index);
								}

								if (index != -1)
								{
									this.FocusedCell = new CellPos(this.FocusedCell.Row, index);
								}
								else
								{
									this.FocusedCell = CellPos.Empty;
								}
							}
						}

						if (columnHeaderRect.X <= 0)
						{
							this.Invalidate(this.PseudoClientRect);
						}
						else if (columnHeaderRect.Left <= this.PseudoClientRect.Right)
						{
							this.Invalidate(new Rectangle(columnHeaderRect.X, 
								this.PseudoClientRect.Top, 
								this.PseudoClientRect.Right-columnHeaderRect.X, 
								this.PseudoClientRect.Height));
						}

						this.UpdateScrollBars();
					
						break;
					}

					case ColumnEventType.TextChanged:
					case ColumnEventType.StateChanged:
					case ColumnEventType.ImageChanged:
					case ColumnEventType.HeaderAlignmentChanged:
					{
						if (columnHeaderRect.IntersectsWith(this.HeaderRectangle))
						{
							this.Invalidate(columnHeaderRect);
						}
					
						break;
					}

					case ColumnEventType.AlignmentChanged:
					case ColumnEventType.RendererChanged:
					case ColumnEventType.EnabledChanged:
					{
						if (e.EventType == ColumnEventType.EnabledChanged)
						{
							if (e.Index == this.FocusedCell.Column)
							{
								this.FocusedCell = CellPos.Empty;
							}
						}
						
						if (columnHeaderRect.IntersectsWith(this.HeaderRectangle))
						{
							this.Invalidate(new Rectangle(columnHeaderRect.X, 
								this.PseudoClientRect.Top, 
								columnHeaderRect.Width, 
								this.PseudoClientRect.Height));
						}
					
						break;
					}
				}

				if (ColumnPropertyChanged != null)
				{
					ColumnPropertyChanged(e.Column, e);
				}
			}
		}
Beispiel #5
0
        /// <summary>
        /// Raises the PropertyChanged event
        /// </summary>
        /// <param name="e">A ColumnEventArgs that contains the event data</param>
        protected virtual void OnPropertyChanged(ColumnEventArgs e)
        {
            if (this.ColumnModel != null)
            {
                e.SetIndex(this.ColumnModel.Columns.IndexOf(this));
            }

            if (this.CanRaiseEvents)
            {
                if (this.ColumnModel != null)
                {
                    this.ColumnModel.OnColumnPropertyChanged(e);
                }

                if (PropertyChanged != null)
                {
                    PropertyChanged(this, e);
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// Raises the ColumnAutoResize event.
        /// </summary>
        /// <param name="e"></param>
        protected internal virtual void OnColumnAutoResize(ColumnEventArgs e)
        {
            if (this.CanRaiseEvents)
            {
                int w = GetAutoColumnWidth(e.Index);
                if (w > 0)
                {
                    if (e.Column.Width != w + 5)
                        this.Invalidate();
                    e.Column.Width = w + 5;
                }

                if (ColumnAutoResize != null)
                    ColumnAutoResize(e.Column, e);
            }
        }
Beispiel #7
0
 /// <summary>
 /// Resizes all columns to their minimum width that still shows all the cells content.
 /// </summary>
 public void AutoResizeColumnWidths()
 {
     for (int i = 0; i < this.ColumnModel.Columns.Count; i++)
     {
         Column c = this.ColumnModel.Columns[i];
         ColumnEventArgs args = new ColumnEventArgs(c, i, ColumnEventType.WidthChanged, c.Width);
         OnColumnAutoResize(args);
     }
 }
Beispiel #8
0
        /// <summary>
        /// Raises the ColumnPropertyChanged event
        /// </summary>
        /// <param name="e">A ColumnEventArgs that contains the event data</param>
        internal void OnColumnPropertyChanged(ColumnEventArgs e)
        {
            if (e.EventType == ColumnEventType.WidthChanged || e.EventType == ColumnEventType.VisibleChanged)
            {
                this.Columns.RecalcWidthCache();
            }

            if (this.CanRaiseEvents)
            {
                if (this.Table != null)
                {
                    this.Table.OnColumnPropertyChanged(e);
                }
            }
        }