

| Type | Description | |||
| Item as HITEM | A long expression that indicates the handle of the newly inserted item. |
Use the AddItem event to notify your application that a new item has been inserted into the Items collection. The AddItem, InsertItem and InsertControlItem methods fire the AddItem event. The PutItems method invokes the AddItem event each time a new item is added. If the user binds the control to an ADO recordset using the DataSource property, AddEvent is called each time the control inserts a new item.
Syntax for AddItem event, /NET version, on:
private void AddItem(object sender,int Item)
{
}
Private Sub AddItem(ByVal sender As System.Object,ByVal Item As Integer) Handles AddItem End Sub |
private void AddItem(object sender, AxEXGRIDLib._IGridEvents_AddItemEvent e)
{
}
void OnAddItem(long Item)
{
}
void __fastcall AddItem(TObject *Sender,Exgridlib_tlb::HITEM Item)
{
}
procedure AddItem(ASender: TObject; Item : HITEM); begin end; procedure AddItem(sender: System.Object; e: AxEXGRIDLib._IGridEvents_AddItemEvent); begin end; begin event AddItem(long Item) end event AddItem Private Sub AddItem(ByVal sender As System.Object, ByVal e As AxEXGRIDLib._IGridEvents_AddItemEvent) Handles AddItem End Sub Private Sub AddItem(ByVal Item As EXGRIDLibCtl.HITEM) End Sub Private Sub AddItem(ByVal Item As Long) End Sub LPARAMETERS Item PROCEDURE OnAddItem(oGrid,Item) RETURN |
<SCRIPT EVENT="AddItem(Item)" LANGUAGE="JScript"> </SCRIPT> <SCRIPT LANGUAGE="VBScript"> Function AddItem(Item) End Function </SCRIPT> Procedure OnComAddItem HITEM llItem Forward Send OnComAddItem llItem End_Procedure METHOD OCX_AddItem(Item) CLASS MainDialog RETURN NIL void onEvent_AddItem(int _Item)
{
}
function AddItem as v (Item as OLE::Exontrol.Grid.1::HITEM) end function function nativeObject_AddItem(Item) return |
The following VB sample changes the item's background color:
Private Sub Grid1_AddItem(ByVal Item As EXGRIDLibCtl.HITEM)
With Grid1.Items
.ItemBackColor(Item) = IIf(.ItemToIndex(Item) Mod 2 = 0, vbBlue, vbRed)
End With
End Sub
The following VB sample adds WS_HSCROLL and WS_VSCROLL window styles to the container window that hosts an ActiveX control
Private Const WS_VSCROLL = &H200000 Private Const WS_HSCROLL = &H100000
...
With Grid1.Items .InsertControlItem , "https://www.exontrol.com" End With
...
Private Sub Grid1_AddItem(ByVal Item As EXGRIDLibCtl.HITEM) With Grid1.Items If (.ItemControlID(Item) Like "http://www.*") Then ' Some of controls like the WEB control, require some additional window styles ( like WS_HSCROLL and WS_VSCROLL window styles ) ' for the window that hosts that WEB control, to allow scrolling the web page .ItemWindowHostCreateStyle(Item) = .ItemWindowHostCreateStyle(Item) + WS_HSCROLL + WS_VSCROLL End If End With End Sub
The following C++ sample changes the item's foreground color when a new items is inserted:
#include "Items.h"
void OnAddItemGrid1(long Item)
{
if ( ::IsWindow( m_grid.m_hWnd ) )
{
CItems items = m_grid.GetItems();
items.SetItemForeColor( Item, RGB(0,0,255) );
}
}
The following VB.NET sample changes the item's foreground color when a new items is inserted:
Shared Function ToUInt32(ByVal c As Color) As UInt32
Dim i As Long
i = c.R
i = i + 256 * c.G
i = i + 256 * 256 * c.B
ToUInt32 = Convert.ToUInt32(i)
End Function
Private Sub AxGrid1_AddItem(ByVal sender As Object, ByVal e As AxEXGRIDLib._IGridEvents_AddItemEvent) Handles AxGrid1.AddItem
AxGrid1.Items.ItemForeColor(e.item) = ToUInt32(Color.Blue)
End Sub
The following C# sample changes the item's foreground color when a new items is inserted:
private UInt32 ToUInt32(Color c)
{
long i;
i = c.R;
i = i + 256 * c.G;
i = i + 256 * 256 * c.B;
return Convert.ToUInt32(i);
}
private void axGrid1_AddItem(object sender, AxEXGRIDLib._IGridEvents_AddItemEvent e)
{
axGrid1.Items.set_ItemForeColor(e.item, ToUInt32(Color.Blue));
}
The following VFP sample changes the item's foreground color when a new items is inserted:
*** ActiveX Control Event *** LPARAMETERS item with thisform.Grid1.Items .DefaultItem = item .ItemForeColor( 0 ) = RGB(0,0,255 ) endwith