method Chart.UndoRemoveAction ([Action as Variant], [Count as Variant])
Removes the last the undo actions that can be performed in the chart.

 TypeDescription 
   Action as Variant [optional] A long expression that specifies the action being removed. If missing or -1, all actions are removed from the undo queue. For instance, UndoRemoveAction(2) removes only AddBar actions in the undo stack.  
   Count as Variant [optional] A long expression that indicates the number of actions to be removed. If missing or -1, all actions are removed. For instance, UndoRemoveAction(2,1) removes only the last AddBar action from the undo stack  
Use the UndoRemoveAction method to remove the last action from the undo queue. Use the UndoRemoveAction() ( with no parameters ) to remove all undo actions. The UndoListAction property retrieves the list of actions that an undo operation can perform. The RedoRemoveAction method removes the first action to be performed if the Redo method is invoked. For instance, let's say that during the AddLink event, you decide that the link being added should be removed, and so, you do not need to record the last RemoveLink action. In other words, you need to call the UndoRemoveAction( exChartUndoRedoRemoveLink, 1 ) removes the last RemoveLink action from the undo stack.

The Undo/Redo manager of the chart records operations in the following format:

The following samples shows preventing adding the AddLink and RemoveLink undo operations when  AddLink event occurs. 

VBA (MS Access, Excell...)

' AddLink event - Occurs when the user links two bars using the mouse.
Private Sub G2antt1_AddLink(ByVal LinkKey As String)
	With G2antt1
		.Items.RemoveLink LinkKey
		.Chart.UndoRemoveAction 7,1
		.Chart.UndoRemoveAction 8,1
		Debug.Print(.Chart.UndoListAction())
	End With
End Sub

' ChartEndChanging event - Occurs after the chart has been changed.
Private Sub G2antt1_ChartEndChanging(ByVal Operation As Long)
	With G2antt1
		Debug.Print(.Chart.UndoListAction())
	End With
End Sub

With G2antt1
	.BeginUpdate 
	.Columns.Add "Tasks"
	With .Chart
		.AllowUndoRedo = True
		.FirstVisibleDate = #6/20/2005#
		.AllowLinkBars = True
		.LevelCount = 2
		.PaneWidth(0) = 48
	End With
	With .Items
		.AddBar .AddItem("Task 1"),"Task",#6/21/2005#,#6/25/2005#,""
		.AddBar .AddItem("Task 2"),"Task",#6/28/2005#,#7/2/2005#,""
	End With
	.EndUpdate 
End With

VB6

' AddLink event - Occurs when the user links two bars using the mouse.
Private Sub G2antt1_AddLink(ByVal LinkKey As String)
	With G2antt1
		.Items.RemoveLink LinkKey
		.Chart.UndoRemoveAction 7,1
		.Chart.UndoRemoveAction 8,1
		Debug.Print(.Chart.UndoListAction())
	End With
End Sub

' ChartEndChanging event - Occurs after the chart has been changed.
Private Sub G2antt1_ChartEndChanging(ByVal Operation As EXG2ANTTLibCtl.BarOperationEnum)
	With G2antt1
		Debug.Print(.Chart.UndoListAction())
	End With
End Sub

With G2antt1
	.BeginUpdate 
	.Columns.Add "Tasks"
	With .Chart
		.AllowUndoRedo = True
		.FirstVisibleDate = #6/20/2005#
		.AllowLinkBars = True
		.LevelCount = 2
		.PaneWidth(0) = 48
	End With
	With .Items
		.AddBar .AddItem("Task 1"),"Task",#6/21/2005#,#6/25/2005#,""
		.AddBar .AddItem("Task 2"),"Task",#6/28/2005#,#7/2/2005#,""
	End With
	.EndUpdate 
End With

VB.NET

' AddLink event - Occurs when the user links two bars using the mouse.
Private Sub Exg2antt1_AddLink(ByVal sender As System.Object,ByVal LinkKey As String) Handles Exg2antt1.AddLink
	With Exg2antt1
		.Items.RemoveLink(LinkKey)
		.Chart.UndoRemoveAction(7,1)
		.Chart.UndoRemoveAction(8,1)
		Debug.Print(.Chart.get_UndoListAction())
	End With
End Sub

' ChartEndChanging event - Occurs after the chart has been changed.
Private Sub Exg2antt1_ChartEndChanging(ByVal sender As System.Object,ByVal Operation As exontrol.EXG2ANTTLib.BarOperationEnum) Handles Exg2antt1.ChartEndChanging
	With Exg2antt1
		Debug.Print(.Chart.get_UndoListAction())
	End With
End Sub

With Exg2antt1
	.BeginUpdate()
	.Columns.Add("Tasks")
	With .Chart
		.AllowUndoRedo = True
		.FirstVisibleDate = #6/20/2005#
		.AllowLinkBars = True
		.LevelCount = 2
		.set_PaneWidth(False,48)
	End With
	With .Items
		.AddBar(.AddItem("Task 1"),"Task",#6/21/2005#,#6/25/2005#,"")
		.AddBar(.AddItem("Task 2"),"Task",#6/28/2005#,#7/2/2005#,"")
	End With
	.EndUpdate()
End With

VB.NET for /COM

' AddLink event - Occurs when the user links two bars using the mouse.
Private Sub AxG2antt1_AddLink(ByVal sender As System.Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_AddLinkEvent) Handles AxG2antt1.AddLink
	With AxG2antt1
		.Items.RemoveLink(e.linkKey)
		.Chart.UndoRemoveAction(7,1)
		.Chart.UndoRemoveAction(8,1)
		Debug.Print(.Chart.UndoListAction())
	End With
End Sub

' ChartEndChanging event - Occurs after the chart has been changed.
Private Sub AxG2antt1_ChartEndChanging(ByVal sender As System.Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_ChartEndChangingEvent) Handles AxG2antt1.ChartEndChanging
	With AxG2antt1
		Debug.Print(.Chart.UndoListAction())
	End With
End Sub

With AxG2antt1
	.BeginUpdate()
	.Columns.Add("Tasks")
	With .Chart
		.AllowUndoRedo = True
		.FirstVisibleDate = #6/20/2005#
		.AllowLinkBars = True
		.LevelCount = 2
		.PaneWidth(False) = 48
	End With
	With .Items
		.AddBar(.AddItem("Task 1"),"Task",#6/21/2005#,#6/25/2005#,"")
		.AddBar(.AddItem("Task 2"),"Task",#6/28/2005#,#7/2/2005#,"")
	End With
	.EndUpdate()
End With

C++

// AddLink event - Occurs when the user links two bars using the mouse.
void OnAddLinkG2antt1(LPCTSTR LinkKey)
{
	/*
		Copy and paste the following directives to your header file as
		it defines the namespace 'EXG2ANTTLib' for the library: 'ExG2antt 1.0 Control Library'
		#import <ExG2antt.dll>
		using namespace EXG2ANTTLib;
	*/
	EXG2ANTTLib::IG2anttPtr spG2antt1 = GetDlgItem(IDC_G2ANTT1)->GetControlUnknown();
	spG2antt1->GetItems()->RemoveLink(LinkKey);
	spG2antt1->GetChart()->UndoRemoveAction(long(7),long(1));
	spG2antt1->GetChart()->UndoRemoveAction(long(8),long(1));
	OutputDebugStringW(spG2antt1->GetChart()->GetUndoListAction(vtMissing,vtMissing));
}

// ChartEndChanging event - Occurs after the chart has been changed.
void OnChartEndChangingG2antt1(long Operation)
{
	EXG2ANTTLib::IG2anttPtr spG2antt1 = GetDlgItem(IDC_G2ANTT1)->GetControlUnknown();
	OutputDebugStringW(spG2antt1->GetChart()->GetUndoListAction(vtMissing,vtMissing));
}

EXG2ANTTLib::IG2anttPtr spG2antt1 = GetDlgItem(IDC_G2ANTT1)->GetControlUnknown();
spG2antt1->BeginUpdate();
spG2antt1->GetColumns()->Add(L"Tasks");
EXG2ANTTLib::IChartPtr var_Chart = spG2antt1->GetChart();
	var_Chart->PutAllowUndoRedo(VARIANT_TRUE);
	var_Chart->PutFirstVisibleDate("6/20/2005");
	var_Chart->PutAllowLinkBars(VARIANT_TRUE);
	var_Chart->PutLevelCount(2);
	var_Chart->PutPaneWidth(VARIANT_FALSE,48);
EXG2ANTTLib::IItemsPtr var_Items = spG2antt1->GetItems();
	var_Items->AddBar(var_Items->AddItem("Task 1"),"Task","6/21/2005","6/25/2005","",vtMissing);
	var_Items->AddBar(var_Items->AddItem("Task 2"),"Task","6/28/2005","7/2/2005","",vtMissing);
spG2antt1->EndUpdate();

C#

// AddLink event - Occurs when the user links two bars using the mouse.
private void exg2antt1_AddLink(object sender,string LinkKey)
{
	exg2antt1.Items.RemoveLink(LinkKey);
	exg2antt1.Chart.UndoRemoveAction(7,1);
	exg2antt1.Chart.UndoRemoveAction(8,1);
	System.Diagnostics.Debug.Print(exg2antt1.Chart.get_UndoListAction(null,null));
}
//this.exg2antt1.AddLink += new exontrol.EXG2ANTTLib.exg2antt.AddLinkEventHandler(this.exg2antt1_AddLink);

// ChartEndChanging event - Occurs after the chart has been changed.
private void exg2antt1_ChartEndChanging(object sender,exontrol.EXG2ANTTLib.BarOperationEnum Operation)
{
	System.Diagnostics.Debug.Print(exg2antt1.Chart.get_UndoListAction(null,null));
}
//this.exg2antt1.ChartEndChanging += new exontrol.EXG2ANTTLib.exg2antt.ChartEndChangingEventHandler(this.exg2antt1_ChartEndChanging);

exg2antt1.BeginUpdate();
exg2antt1.Columns.Add("Tasks");
exontrol.EXG2ANTTLib.Chart var_Chart = exg2antt1.Chart;
	var_Chart.AllowUndoRedo = true;
	var_Chart.FirstVisibleDate = Convert.ToDateTime("6/20/2005");
	var_Chart.AllowLinkBars = true;
	var_Chart.LevelCount = 2;
	var_Chart.set_PaneWidth(false,48);
exontrol.EXG2ANTTLib.Items var_Items = exg2antt1.Items;
	var_Items.AddBar(var_Items.AddItem("Task 1"),"Task",Convert.ToDateTime("6/21/2005"),Convert.ToDateTime("6/25/2005"),"",null);
	var_Items.AddBar(var_Items.AddItem("Task 2"),"Task",Convert.ToDateTime("6/28/2005"),Convert.ToDateTime("7/2/2005"),"",null);
exg2antt1.EndUpdate();

C# for /COM

// AddLink event - Occurs when the user links two bars using the mouse.
private void axG2antt1_AddLink(object sender, AxEXG2ANTTLib._IG2anttEvents_AddLinkEvent e)
{
	axG2antt1.Items.RemoveLink(e.linkKey);
	axG2antt1.Chart.UndoRemoveAction(7,1);
	axG2antt1.Chart.UndoRemoveAction(8,1);
	System.Diagnostics.Debug.Print(axG2antt1.Chart.get_UndoListAction(null,null));
}
//this.axG2antt1.AddLink += new AxEXG2ANTTLib._IG2anttEvents_AddLinkEventHandler(this.axG2antt1_AddLink);

// ChartEndChanging event - Occurs after the chart has been changed.
private void axG2antt1_ChartEndChanging(object sender, AxEXG2ANTTLib._IG2anttEvents_ChartEndChangingEvent e)
{
	System.Diagnostics.Debug.Print(axG2antt1.Chart.get_UndoListAction(null,null));
}
//this.axG2antt1.ChartEndChanging += new AxEXG2ANTTLib._IG2anttEvents_ChartEndChangingEventHandler(this.axG2antt1_ChartEndChanging);

axG2antt1.BeginUpdate();
axG2antt1.Columns.Add("Tasks");
EXG2ANTTLib.Chart var_Chart = axG2antt1.Chart;
	var_Chart.AllowUndoRedo = true;
	var_Chart.FirstVisibleDate = Convert.ToDateTime("6/20/2005");
	var_Chart.AllowLinkBars = true;
	var_Chart.LevelCount = 2;
	var_Chart.set_PaneWidth(false,48);
EXG2ANTTLib.Items var_Items = axG2antt1.Items;
	var_Items.AddBar(var_Items.AddItem("Task 1"),"Task",Convert.ToDateTime("6/21/2005"),Convert.ToDateTime("6/25/2005"),"",null);
	var_Items.AddBar(var_Items.AddItem("Task 2"),"Task",Convert.ToDateTime("6/28/2005"),Convert.ToDateTime("7/2/2005"),"",null);
axG2antt1.EndUpdate();

Delphi 8 (.NET only)

// AddLink event - Occurs when the user links two bars using the mouse.
procedure TWinForm1.AxG2antt1_AddLink(sender: System.Object; e: AxEXG2ANTTLib._IG2anttEvents_AddLinkEvent);
begin
	with AxG2antt1 do
	begin
		Items.RemoveLink(TObject(e.linkKey));
		Chart.UndoRemoveAction(TObject(7),TObject(1));
		Chart.UndoRemoveAction(TObject(8),TObject(1));
		OutputDebugString(Chart.UndoListAction[Nil,Nil]);
	end
end;

// ChartEndChanging event - Occurs after the chart has been changed.
procedure TWinForm1.AxG2antt1_ChartEndChanging(sender: System.Object; e: AxEXG2ANTTLib._IG2anttEvents_ChartEndChangingEvent);
begin
	with AxG2antt1 do
	begin
		OutputDebugString(Chart.UndoListAction[Nil,Nil]);
	end
end;

with AxG2antt1 do
begin
	BeginUpdate();
	Columns.Add('Tasks');
	with Chart do
	begin
		AllowUndoRedo := True;
		FirstVisibleDate := '6/20/2005';
		AllowLinkBars := True;
		LevelCount := 2;
		PaneWidth[False] := 48;
	end;
	with Items do
	begin
		AddBar(AddItem('Task 1'),'Task','6/21/2005','6/25/2005','',Nil);
		AddBar(AddItem('Task 2'),'Task','6/28/2005','7/2/2005','',Nil);
	end;
	EndUpdate();
end

Delphi (standard)

// AddLink event - Occurs when the user links two bars using the mouse.
procedure TForm1.G2antt1AddLink(ASender: TObject; LinkKey : WideString);
begin
	with G2antt1 do
	begin
		Items.RemoveLink(OleVariant(LinkKey));
		Chart.UndoRemoveAction(OleVariant(7),OleVariant(1));
		Chart.UndoRemoveAction(OleVariant(8),OleVariant(1));
		OutputDebugString(Chart.UndoListAction[Null,Null]);
	end
end;

// ChartEndChanging event - Occurs after the chart has been changed.
procedure TForm1.G2antt1ChartEndChanging(ASender: TObject; Operation : BarOperationEnum);
begin
	with G2antt1 do
	begin
		OutputDebugString(Chart.UndoListAction[Null,Null]);
	end
end;

with G2antt1 do
begin
	BeginUpdate();
	Columns.Add('Tasks');
	with Chart do
	begin
		AllowUndoRedo := True;
		FirstVisibleDate := '6/20/2005';
		AllowLinkBars := True;
		LevelCount := 2;
		PaneWidth[False] := 48;
	end;
	with Items do
	begin
		AddBar(AddItem('Task 1'),'Task','6/21/2005','6/25/2005','',Null);
		AddBar(AddItem('Task 2'),'Task','6/28/2005','7/2/2005','',Null);
	end;
	EndUpdate();
end

VFP

*** AddLink event - Occurs when the user links two bars using the mouse. ***
LPARAMETERS LinkKey
	with thisform.G2antt1
		.Items.RemoveLink(LinkKey)
		.Chart.UndoRemoveAction(7,1)
		.Chart.UndoRemoveAction(8,1)
		DEBUGOUT(.Chart.UndoListAction())
	endwith

*** ChartEndChanging event - Occurs after the chart has been changed. ***
LPARAMETERS Operation
	with thisform.G2antt1
		DEBUGOUT(.Chart.UndoListAction())
	endwith

with thisform.G2antt1
	.BeginUpdate
	.Columns.Add("Tasks")
	with .Chart
		.AllowUndoRedo = .T.
		.FirstVisibleDate = {^2005-6-20}
		.AllowLinkBars = .T.
		.LevelCount = 2
		.PaneWidth(0) = 48
	endwith
	with .Items
		.AddBar(.AddItem("Task 1"),"Task",{^2005-6-21},{^2005-6-25},"")
		.AddBar(.AddItem("Task 2"),"Task",{^2005-6-28},{^2005-7-2},"")
	endwith
	.EndUpdate
endwith


Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.