![]() | 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.
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 , "http://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