ReoGrid Forum

Fast and powerful .NET Spreadsheet Component

You are not logged in.

Announcement

This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.

https://github.com/unvell/ReoGrid/issues

#1 2014-06-17 15:17:48

fjzwjlfnx
Member
Registered: 2014-06-17
Posts: 7

some suggestion:

I hope  Hide,Unhide  functions  can  finished  by  grid.DoAction(...),because DoAction can undo and redo!

            thank you!

Offline

#2 2014-06-17 18:48:45

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: some suggestion:

OK. Before the next version which contains this changes get released, add the code below into your project, these classes will perform the do/undo/redo actions:

	#region Hide/Unhide Actions
	public abstract class RangeOperationAction : RGAction
	{
		public ReoGridControl Grid { get; set; }
		public ReoGridRange Range { get; set; }

		public RangeOperationAction(ReoGridControl grid, ReoGridRange range)
		{
			this.Grid = grid;
			this.Range = range;
		}
	}

	/// <summary>
	/// Hide specified rows action
	/// </summary>
	public class HideRowsAction : RangeOperationAction
	{
		public HideRowsAction(ReoGridControl grid, int row, int count)
			: base(grid, new ReoGridRange(row, 0, count, -1)) { }

		public override void Do()
		{
			base.Grid.HideRows(base.Range.Row, base.Range.Rows);
		}

		public override void Undo()
		{
			base.Grid.ShowRows(base.Range.Row, base.Range.Rows);
		}

		public override string GetName() { return "Hide Rows"; }
	}

	/// <summary>
	/// Unhide specified rows action
	/// </summary>
	public class UnhideRowsAction : RangeOperationAction
	{
		public UnhideRowsAction(ReoGridControl grid, int row, int count)
			: base(grid, new ReoGridRange(row, 0, count, -1)) { }

		public override void Do()
		{
			base.Grid.ShowRows(base.Range.Row, base.Range.Rows);
		}

		public override void Undo()
		{
			base.Grid.HideRows(base.Range.Row, base.Range.Rows);
		}

		public override string GetName() { return "Unhide Rows"; }
	}

	/// <summary>
	/// Hide specified columns action
	/// </summary>
	public class HideColumnsAction : RangeOperationAction
	{
		public HideColumnsAction(ReoGridControl grid, int row, int count)
			: base(grid, new ReoGridRange(row, 0, count, -1)) { }

		public override void Do()
		{
			base.Grid.HideColumns(base.Range.Row, base.Range.Rows);
		}

		public override void Undo()
		{
			base.Grid.ShowColumns(base.Range.Row, base.Range.Rows);
		}

		public override string GetName() { return "Hide Columns"; }
	}

	/// <summary>
	/// Unhide specified columns action
	/// </summary>
	public class UnhideColumnsAction : RangeOperationAction
	{
		public UnhideColumnsAction(ReoGridControl grid, int row, int count)
			: base(grid, new ReoGridRange(row, 0, count, -1)) { }

		public override void Do()
		{
			base.Grid.ShowColumns(base.Range.Row, base.Range.Rows);
		}

		public override void Undo()
		{
			base.Grid.HideColumns(base.Range.Row, base.Range.Rows);
		}

		public override string GetName() { return "Unhide Columns"; }
	}
	#endregion // Hide/Unhide Actions

Usage:

grid.DoAction(new HideRowsAction(this.grid, grid.SelectionRange.Row, grid.SelectionRange.Rows));
grid.DoAction(new UnhideRowsAction(this.grid, grid.SelectionRange.Row, grid.SelectionRange.Rows));
grid.DoAction(new HideColumnsAction(this.grid, grid.SelectionRange.Col, grid.SelectionRange.Cols));
grid.DoAction(new UnhideColumnsAction(this.grid, grid.SelectionRange.Col, grid.SelectionRange.Cols));

thanks, Jing

Last edited by Jingwood (2014-06-17 18:49:44)

Offline

Board footer

Powered by FluxBB