event AddGroupItem (Item as HITEM)
Occurs after a new Group Item has been inserted to Items collection.

 TypeDescription 
   Item as HITEM A Long expression that indicates the handle of the grouping items being inserted.   
The AddGroupItem event is fired for each new item to be inserted in the Items collection during the grouping. The GroupItem method determines the index of the column that indicates the column being grouped. In other words, the CellCaption(Item,GroupItem(Item) ) gets the default caption to be displayed for the grouping item. The Ungroup method removes all grouping items. For instance, when a column gets grouped by, the control sorts by that column, collects the unique values being found, and add a new item for each value found, by adding the items of the same value as children.

The AddGroupItem event can be used in any of the followings:

Syntax for AddGroupItem event, /NET version, on:

private void AddGroupItem(object sender,int Item)
{
}

Private Sub AddGroupItem(ByVal sender As System.Object,ByVal Item As Integer) Handles AddGroupItem
End Sub

Syntax for AddGroupItem event, /COM version, on:

private void AddGroupItem(object sender, AxEXGRIDLib._IGridEvents_AddGroupItemEvent e)
{
}

void OnAddGroupItem(long Item)
{
}

void __fastcall AddGroupItem(TObject *Sender,Exgridlib_tlb::HITEM Item)
{
}

procedure AddGroupItem(ASender: TObject; Item : HITEM);
begin
end;

procedure AddGroupItem(sender: System.Object; e: AxEXGRIDLib._IGridEvents_AddGroupItemEvent);
begin
end;

begin event AddGroupItem(long Item)
end event AddGroupItem

Private Sub AddGroupItem(ByVal sender As System.Object, ByVal e As AxEXGRIDLib._IGridEvents_AddGroupItemEvent) Handles AddGroupItem
End Sub

Private Sub AddGroupItem(ByVal Item As EXGRIDLibCtl.HITEM)
End Sub

Private Sub AddGroupItem(ByVal Item As Long)
End Sub

LPARAMETERS Item

PROCEDURE OnAddGroupItem(oGrid,Item)
RETURN

Syntax for AddGroupItem event, /COM version (others), on:

<SCRIPT EVENT="AddGroupItem(Item)" LANGUAGE="JScript">
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">
Function AddGroupItem(Item)
End Function
</SCRIPT>

Procedure OnComAddGroupItem HITEM llItem
	Forward Send OnComAddGroupItem llItem
End_Procedure

METHOD OCX_AddGroupItem(Item) CLASS MainDialog
RETURN NIL

void onEvent_AddGroupItem(int _Item)
{
}

function AddGroupItem as v (Item as OLE::Exontrol.Grid.1::HITEM)
end function

function nativeObject_AddGroupItem(Item)
return

The following samples shows how to underline the grouping items, and add a footer item to show the total/sum on the column with the index 6:

VBA
Private Sub Grid1_AddGroupItem(ByVal Item As Long)
	With Grid1
		With .Items
			.CellUnderline(Item,.GroupItem(Item)) = True
			h = .InsertItem(Item,0,"")
			.SelectableItem(h) = False
			.CellValue(h,6) = "sum(parent,rec,dbl(%6))"
			.CellValueFormat(h,6) = 5 ' ValueFormatEnum.exTotalField Or ValueFormatEnum.exHTML
			.FormatCell(h,6) = "`<font ;7><b>Sum</b>: ` + value"
		End With
	End With
End Sub
VB
Private Sub Grid1_AddGroupItem(ByVal Item As EXGRIDLibCtl.HITEM)
	With Grid1
		With .Items
			.CellUnderline(Item,.GroupItem(Item)) = True
			h = .InsertItem(Item,0,"")
			.SelectableItem(h) = False
			.CellValue(h,6) = "sum(parent,rec,dbl(%6))"
			.CellValueFormat(h,6) = ValueFormatEnum.exTotalField Or ValueFormatEnum.exHTML
			.FormatCell(h,6) = "`<font ;7><b>Sum</b>: ` + value"
		End With
	End With
End Sub
VB.NET
Private Sub Exgrid1_AddGroupItem(ByVal sender As System.Object,ByVal Item As Integer) Handles Exgrid1.AddGroupItem
	Dim h
	With Exgrid1
		With .Items
			.set_CellUnderline(Item,.get_GroupItem(Item),True)
			h = .InsertItem(Item,0,"")
			.set_SelectableItem(h,False)
			.set_CellValue(h,6,"sum(parent,rec,dbl(%6))")
			.set_CellValueFormat(h,6,exontrol.EXGRIDLib.ValueFormatEnum.exTotalField Or exontrol.EXGRIDLib.ValueFormatEnum.exHTML)
			.set_FormatCell(h,6,"`<font ;7><b>Sum</b>: ` + value")
		End With
	End With
End Sub
C++
void OnAddGroupItemGrid1(long Item)
{
	/*
		Copy and paste the following directives to your header file as
		it defines the namespace 'EXGRIDLib' for the library: 'ExGrid 1.0 Control Library'
		#import <ExGrid.dll>
		using namespace EXGRIDLib;
	*/
	EXGRIDLib::IGridPtr spGrid1 = GetDlgItem(IDC_GRID1)->GetControlUnknown();
	EXGRIDLib::IItemsPtr var_Items = spGrid1->GetItems();
		var_Items->PutCellUnderline(Item,var_Items->GetGroupItem(Item),VARIANT_TRUE);
		long h = var_Items->InsertItem(Item,long(0),"");
		var_Items->PutSelectableItem(h,VARIANT_FALSE);
		var_Items->PutCellValue(h,long(6),"sum(parent,rec,dbl(%6))");
		var_Items->PutCellValueFormat(h,long(6),EXGRIDLib::ValueFormatEnum(EXGRIDLib::exTotalField | EXGRIDLib::exHTML));
		var_Items->PutFormatCell(h,long(6),L"`<font ;7><b>Sum</b>: ` + value");
}
C++ Builder
void __fastcall TForm1::Grid1AddGroupItem(TObject *Sender,Exgridlib_tlb::HITEM Item)
{
	Exgridlib_tlb::IItemsPtr var_Items = Grid1->Items;
		var_Items->set_CellUnderline(TVariant(Item),TVariant(var_Items->get_GroupItem(Item)),true);
		long h = var_Items->InsertItem(Item,TVariant(0),TVariant(""));
		var_Items->set_SelectableItem(h,false);
		var_Items->set_CellValue(TVariant(h),TVariant(6),TVariant("sum(parent,rec,dbl(%6))"));
		var_Items->set_CellValueFormat(TVariant(h),TVariant(6),Exgridlib_tlb::ValueFormatEnum::exTotalField | Exgridlib_tlb::ValueFormatEnum::exHTML);
		var_Items->set_FormatCell(TVariant(h),TVariant(6),L"`<font ;7><b>Sum</b>: ` + value");
}
C#
private void exgrid1_AddGroupItem(object sender,int Item)
{
	exontrol.EXGRIDLib.Items var_Items = exgrid1.Items;
		var_Items.set_CellUnderline(Item,var_Items.get_GroupItem(Item),true);
		int h = var_Items.InsertItem(Item,0,"");
		var_Items.set_SelectableItem(h,false);
		var_Items.set_CellValue(h,6,"sum(parent,rec,dbl(%6))");
		var_Items.set_CellValueFormat(h,6,exontrol.EXGRIDLib.ValueFormatEnum.exTotalField | exontrol.EXGRIDLib.ValueFormatEnum.exHTML);
		var_Items.set_FormatCell(h,6,"`<font ;7><b>Sum</b>: ` + value");
}
JavaScript
<SCRIPT FOR="Grid1" EVENT="AddGroupItem(Item)" LANGUAGE="JScript">
	var var_Items = Grid1.Items;
		var_Items.CellUnderline(Item,var_Items.GroupItem(Item)) = true;
		var h = var_Items.InsertItem(Item,0,"");
		var_Items.SelectableItem(h) = false;
		var_Items.CellValue(h,6) = "sum(parent,rec,dbl(%6))";
		var_Items.CellValueFormat(h,6) = 5;
		var_Items.FormatCell(h,6) = "`<font ;7><b>Sum</b>: ` + value";
</SCRIPT>
VFP
*** AddGroupItem event - Occurs after a new Group Item has been inserted to Items collection. ***
LPARAMETERS Item
	with thisform.Grid1
		with .Items
			.CellUnderline(Item,.GroupItem(Item)) = .T.
			h = .InsertItem(Item,0,"")
			.SelectableItem(h) = .F.
			.CellValue(h,6) = "sum(parent,rec,dbl(%6))"
			.CellValueFormat(h,6) = 5 && ValueFormatEnum.exTotalField Or ValueFormatEnum.exHTML
			.FormatCell(h,6) = "`<font ;7><b>Sum</b>: ` + value"
		endwith
	endwith
Delphi
procedure TForm1.Grid1AddGroupItem(ASender: TObject; Item : HITEM);
begin
	with Grid1 do
	begin
		with Items do
		begin
			CellUnderline[OleVariant(Item),OleVariant(GroupItem[Item])] := True;
			h := InsertItem(Item,OleVariant(0),'');
			SelectableItem[h] := False;
			CellValue[OleVariant(h),OleVariant(6)] := 'sum(parent,rec,dbl(%6))';
			CellValueFormat[OleVariant(h),OleVariant(6)] := Integer(EXGRIDLib_TLB.exTotalField) Or Integer(EXGRIDLib_TLB.exHTML);
			FormatCell[OleVariant(h),OleVariant(6)] := '`<font ;7><b>Sum</b>: ` + value';
		end;
	end
end;
Visual Objects
METHOD OCX_Exontrol1AddGroupItem(Item) CLASS MainDialog
	local var_Items as IItems
	local h as USUAL
	var_Items := oDCOCX_Exontrol1:Items
		var_Items:[CellUnderline,Item,var_Items:[GroupItem,Item]] := true
		h := var_Items:InsertItem(Item,0,"")
		var_Items:[SelectableItem,h] := false
		var_Items:[CellValue,h,6] := "sum(parent,rec,dbl(%6))"
		var_Items:[CellValueFormat,h,6] := exTotalField | exHTML
		var_Items:[FormatCell,h,6] := "`<font ;7><b>Sum</b>: ` + value"
RETURN NIL

 


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