How can I add or insert child items? VBA (MS Access, Excell...)
With ComboBox1
.LinesAtRoot = -1
.Columns.Add "C1"
.Columns.Add "C2"
With .Items
h = .AddItem("Cell 1")
.CellCaption(h,1) = "Cell 2"
.CellCaption(.InsertItem(h,0,"Cell 3"),1) = "Cell 4"
.CellCaption(.InsertItem(h,0,"Cell 5"),1) = "Cell 6"
.ExpandItem(h) = True
End With
End With
VB6
With ComboBox1
.LinesAtRoot = exLinesAtRoot
.Columns.Add "C1"
.Columns.Add "C2"
With .Items
h = .AddItem("Cell 1")
.CellCaption(h,1) = "Cell 2"
.CellCaption(.InsertItem(h,0,"Cell 3"),1) = "Cell 4"
.CellCaption(.InsertItem(h,0,"Cell 5"),1) = "Cell 6"
.ExpandItem(h) = True
End With
End With
VB.NET
Dim h
With Excombobox1
.LinesAtRoot = exontrol.EXCOMBOBOXLib.LinesAtRootEnum.exLinesAtRoot
.Columns.Add("C1")
.Columns.Add("C2")
With .Items
h = .AddItem("Cell 1")
.set_CellCaption(h,1,"Cell 2")
.set_CellCaption(.InsertItem(h,0,"Cell 3"),1,"Cell 4")
.set_CellCaption(.InsertItem(h,0,"Cell 5"),1,"Cell 6")
.set_ExpandItem(h,True)
End With
End With
VB.NET for /COM
Dim h
With AxComboBox1
.LinesAtRoot = EXCOMBOBOXLib.LinesAtRootEnum.exLinesAtRoot
.Columns.Add("C1")
.Columns.Add("C2")
With .Items
h = .AddItem("Cell 1")
.CellCaption(h,1) = "Cell 2"
.CellCaption(.InsertItem(h,0,"Cell 3"),1) = "Cell 4"
.CellCaption(.InsertItem(h,0,"Cell 5"),1) = "Cell 6"
.ExpandItem(h) = True
End With
End With
C++
/*
Copy and paste the following directives to your header file as
it defines the namespace 'EXCOMBOBOXLib' for the library: 'ExComboBox 1.0 Control Library'
#import <ExComboBox.dll>
using namespace EXCOMBOBOXLib;
*/
EXCOMBOBOXLib::IComboBoxPtr spComboBox1 = GetDlgItem(IDC_COMBOBOX1)->GetControlUnknown();
spComboBox1->PutLinesAtRoot(EXCOMBOBOXLib::exLinesAtRoot);
spComboBox1->GetColumns()->Add(L"C1");
spComboBox1->GetColumns()->Add(L"C2");
EXCOMBOBOXLib::IItemsPtr var_Items = spComboBox1->GetItems();
long h = var_Items->AddItem("Cell 1");
var_Items->PutCellCaption(h,long(1),"Cell 2");
var_Items->PutCellCaption(var_Items->InsertItem(h,long(0),"Cell 3"),long(1),"Cell 4");
var_Items->PutCellCaption(var_Items->InsertItem(h,long(0),"Cell 5"),long(1),"Cell 6");
var_Items->PutExpandItem(h,VARIANT_TRUE);
C++ Builder
ComboBox1->LinesAtRoot = Excomboboxlib_tlb::LinesAtRootEnum::exLinesAtRoot;
ComboBox1->Columns->Add(L"C1");
ComboBox1->Columns->Add(L"C2");
Excomboboxlib_tlb::IItemsPtr var_Items = ComboBox1->Items;
long h = var_Items->AddItem(TVariant("Cell 1"));
var_Items->set_CellCaption(TVariant(h),TVariant(1),TVariant("Cell 2"));
var_Items->set_CellCaption(TVariant(var_Items->InsertItem(h,TVariant(0),TVariant("Cell 3"))),TVariant(1),TVariant("Cell 4"));
var_Items->set_CellCaption(TVariant(var_Items->InsertItem(h,TVariant(0),TVariant("Cell 5"))),TVariant(1),TVariant("Cell 6"));
var_Items->set_ExpandItem(h,true);
C#
excombobox1.LinesAtRoot = exontrol.EXCOMBOBOXLib.LinesAtRootEnum.exLinesAtRoot;
excombobox1.Columns.Add("C1");
excombobox1.Columns.Add("C2");
exontrol.EXCOMBOBOXLib.Items var_Items = excombobox1.Items;
int h = var_Items.AddItem("Cell 1");
var_Items.set_CellCaption(h,1,"Cell 2");
var_Items.set_CellCaption(var_Items.InsertItem(h,0,"Cell 3"),1,"Cell 4");
var_Items.set_CellCaption(var_Items.InsertItem(h,0,"Cell 5"),1,"Cell 6");
var_Items.set_ExpandItem(h,true);
JavaScript
<OBJECT classid="clsid:CF170E7A-4391-44BD-8D93-29F8D2801EF7" id="ComboBox1"></OBJECT>
<SCRIPT LANGUAGE="JScript">
ComboBox1.LinesAtRoot = -1;
ComboBox1.Columns.Add("C1");
ComboBox1.Columns.Add("C2");
var var_Items = ComboBox1.Items;
var h = var_Items.AddItem("Cell 1");
var_Items.CellCaption(h,1) = "Cell 2";
var_Items.CellCaption(var_Items.InsertItem(h,0,"Cell 3"),1) = "Cell 4";
var_Items.CellCaption(var_Items.InsertItem(h,0,"Cell 5"),1) = "Cell 6";
var_Items.ExpandItem(h) = true;
</SCRIPT>
C# for /COM
axComboBox1.LinesAtRoot = EXCOMBOBOXLib.LinesAtRootEnum.exLinesAtRoot;
axComboBox1.Columns.Add("C1");
axComboBox1.Columns.Add("C2");
EXCOMBOBOXLib.Items var_Items = axComboBox1.Items;
int h = var_Items.AddItem("Cell 1");
var_Items.set_CellCaption(h,1,"Cell 2");
var_Items.set_CellCaption(var_Items.InsertItem(h,0,"Cell 3"),1,"Cell 4");
var_Items.set_CellCaption(var_Items.InsertItem(h,0,"Cell 5"),1,"Cell 6");
var_Items.set_ExpandItem(h,true);
X++ (Dynamics Ax 2009)
public void init()
{
COM com_Items;
anytype var_Items;
int h;
;
super();
excombobox1.LinesAtRoot(-1/*exLinesAtRoot*/);
excombobox1.Columns().Add("C1");
excombobox1.Columns().Add("C2");
var_Items = excombobox1.Items(); com_Items = var_Items;
h = com_Items.AddItem("Cell 1");
com_Items.CellCaption(h,COMVariant::createFromInt(1),"Cell 2");
com_Items.CellCaption(com_Items.InsertItem(h,COMVariant::createFromInt(0),"Cell 3"),COMVariant::createFromInt(1),"Cell 4");
com_Items.CellCaption(com_Items.InsertItem(h,COMVariant::createFromInt(0),"Cell 5"),COMVariant::createFromInt(1),"Cell 6");
com_Items.ExpandItem(h,true);
}
Delphi 8 (.NET only)
with AxComboBox1 do
begin
LinesAtRoot := EXCOMBOBOXLib.LinesAtRootEnum.exLinesAtRoot;
Columns.Add('C1');
Columns.Add('C2');
with Items do
begin
h := AddItem('Cell 1');
CellCaption[TObject(h),TObject(1)] := 'Cell 2';
CellCaption[TObject(InsertItem(h,TObject(0),'Cell 3')),TObject(1)] := 'Cell 4';
CellCaption[TObject(InsertItem(h,TObject(0),'Cell 5')),TObject(1)] := 'Cell 6';
ExpandItem[h] := True;
end;
end
Delphi (standard)
with ComboBox1 do
begin
LinesAtRoot := EXCOMBOBOXLib_TLB.exLinesAtRoot;
Columns.Add('C1');
Columns.Add('C2');
with Items do
begin
h := AddItem('Cell 1');
CellCaption[OleVariant(h),OleVariant(1)] := 'Cell 2';
CellCaption[OleVariant(InsertItem(h,OleVariant(0),'Cell 3')),OleVariant(1)] := 'Cell 4';
CellCaption[OleVariant(InsertItem(h,OleVariant(0),'Cell 5')),OleVariant(1)] := 'Cell 6';
ExpandItem[h] := True;
end;
end
VFP
with thisform.ComboBox1
.LinesAtRoot = -1
.Columns.Add("C1")
.Columns.Add("C2")
with .Items
h = .AddItem("Cell 1")
.CellCaption(h,1) = "Cell 2"
.CellCaption(.InsertItem(h,0,"Cell 3"),1) = "Cell 4"
.CellCaption(.InsertItem(h,0,"Cell 5"),1) = "Cell 6"
.ExpandItem(h) = .T.
endwith
endwith
dBASE Plus
local h,oComboBox,var_Items
oComboBox = form.Activex1.nativeObject
oComboBox.LinesAtRoot = -1
oComboBox.Columns.Add("C1")
oComboBox.Columns.Add("C2")
var_Items = oComboBox.Items
h = var_Items.AddItem("Cell 1")
// var_Items.CellCaption(h,1) = "Cell 2"
with (oComboBox)
TemplateDef = [Dim var_Items,h]
TemplateDef = var_Items
TemplateDef = h
Template = [var_Items.CellCaption(h,1) = "Cell 2"]
endwith
// var_Items.CellCaption(var_Items.InsertItem(h,0,"Cell 3"),1) = "Cell 4"
with (oComboBox)
TemplateDef = [Dim var_Items]
TemplateDef = var_Items
Template = [var_Items.CellCaption(var_Items.InsertItem(h,0,"Cell 3"),1) = "Cell 4"]
endwith
// var_Items.CellCaption(var_Items.InsertItem(h,0,"Cell 5"),1) = "Cell 6"
with (oComboBox)
TemplateDef = [Dim var_Items]
TemplateDef = var_Items
Template = [var_Items.CellCaption(var_Items.InsertItem(h,0,"Cell 5"),1) = "Cell 6"]
endwith
// var_Items.ExpandItem(h) = true
with (oComboBox)
TemplateDef = [Dim var_Items,h]
TemplateDef = var_Items
TemplateDef = h
Template = [var_Items.ExpandItem(h) = true]
endwith
XBasic (Alpha Five)
Dim h as N
Dim oComboBox as P
Dim var_Items as P
oComboBox = topparent:CONTROL_ACTIVEX1.activex
oComboBox.LinesAtRoot = -1
oComboBox.Columns.Add("C1")
oComboBox.Columns.Add("C2")
var_Items = oComboBox.Items
h = var_Items.AddItem("Cell 1")
' var_Items.CellCaption(h,1) = "Cell 2"
oComboBox.TemplateDef = "Dim var_Items,h"
oComboBox.TemplateDef = var_Items
oComboBox.TemplateDef = h
oComboBox.Template = "var_Items.CellCaption(h,1) = \"Cell 2\""
' var_Items.CellCaption(var_Items.InsertItem(h,0,"Cell 3"),1) = "Cell 4"
oComboBox.TemplateDef = "Dim var_Items"
oComboBox.TemplateDef = var_Items
oComboBox.Template = "var_Items.CellCaption(var_Items.InsertItem(h,0,\"Cell 3\"),1) = \"Cell 4\""
' var_Items.CellCaption(var_Items.InsertItem(h,0,"Cell 5"),1) = "Cell 6"
oComboBox.TemplateDef = "Dim var_Items"
oComboBox.TemplateDef = var_Items
oComboBox.Template = "var_Items.CellCaption(var_Items.InsertItem(h,0,\"Cell 5\"),1) = \"Cell 6\""
' var_Items.ExpandItem(h) = .t.
oComboBox.TemplateDef = "Dim var_Items,h"
oComboBox.TemplateDef = var_Items
oComboBox.TemplateDef = h
oComboBox.Template = "var_Items.ExpandItem(h) = True"
Visual Objects
local var_Items as IItems
local h as USUAL
oDCOCX_Exontrol1:LinesAtRoot := exLinesAtRoot
oDCOCX_Exontrol1:Columns:Add("C1")
oDCOCX_Exontrol1:Columns:Add("C2")
var_Items := oDCOCX_Exontrol1:Items
h := var_Items:AddItem("Cell 1")
var_Items:[CellCaption,h,1] := "Cell 2"
var_Items:[CellCaption,var_Items:InsertItem(h,0,"Cell 3"),1] := "Cell 4"
var_Items:[CellCaption,var_Items:InsertItem(h,0,"Cell 5"),1] := "Cell 6"
var_Items:[ExpandItem,h] := true
PowerBuilder
OleObject oComboBox,var_Items
any h
oComboBox = ole_1.Object
oComboBox.LinesAtRoot = -1
oComboBox.Columns.Add("C1")
oComboBox.Columns.Add("C2")
var_Items = oComboBox.Items
h = var_Items.AddItem("Cell 1")
var_Items.CellCaption(h,1,"Cell 2")
var_Items.CellCaption(var_Items.InsertItem(h,0,"Cell 3"),1,"Cell 4")
var_Items.CellCaption(var_Items.InsertItem(h,0,"Cell 5"),1,"Cell 6")
var_Items.ExpandItem(h,true)
Visual DataFlex
Procedure OnCreate
Forward Send OnCreate
Set ComLinesAtRoot to OLEexLinesAtRoot
Variant voColumns
Get ComColumns to voColumns
Handle hoColumns
Get Create (RefClass(cComColumns)) to hoColumns
Set pvComObject of hoColumns to voColumns
Get ComAdd of hoColumns "C1" to Nothing
Send Destroy to hoColumns
Variant voColumns1
Get ComColumns to voColumns1
Handle hoColumns1
Get Create (RefClass(cComColumns)) to hoColumns1
Set pvComObject of hoColumns1 to voColumns1
Get ComAdd of hoColumns1 "C2" to Nothing
Send Destroy to hoColumns1
Variant voItems
Get ComItems to voItems
Handle hoItems
Get Create (RefClass(cComItems)) to hoItems
Set pvComObject of hoItems to voItems
Variant h
Get ComAddItem of hoItems "Cell 1" to h
Set ComCellCaption of hoItems h 1 to "Cell 2"
Set ComCellCaption of hoItems (ComInsertItem(hoItems,h,0,"Cell 3")) 1 to "Cell 4"
Set ComCellCaption of hoItems (ComInsertItem(hoItems,h,0,"Cell 5")) 1 to "Cell 6"
Set ComExpandItem of hoItems h to True
Send Destroy to hoItems
End_Procedure
XBase++
#include "AppEvent.ch"
#include "ActiveX.ch"
PROCEDURE Main
LOCAL oForm
LOCAL nEvent := 0, mp1 := NIL, mp2 := NIL, oXbp := NIL
LOCAL oComboBox
LOCAL oItems
LOCAL h
oForm := XbpDialog():new( AppDesktop() )
oForm:drawingArea:clipChildren := .T.
oForm:create( ,,{100,100}, {640,480},, .F. )
oForm:close := {|| PostAppEvent( xbeP_Quit )}
oComboBox := XbpActiveXControl():new( oForm:drawingArea )
oComboBox:CLSID := "Exontrol.ComboBox.1" /*{CF170E7A-4391-44BD-8D93-29F8D2801EF7}*/
oComboBox:create(,, {10,60},{610,370} )
oComboBox:LinesAtRoot := -1/*exLinesAtRoot*/
oComboBox:Columns():Add("C1")
oComboBox:Columns():Add("C2")
oItems := oComboBox:Items()
h := oItems:AddItem("Cell 1")
oItems:SetProperty("CellCaption",h,1,"Cell 2")
oItems:SetProperty("CellCaption",oItems:InsertItem(h,0,"Cell 3"),1,"Cell 4")
oItems:SetProperty("CellCaption",oItems:InsertItem(h,0,"Cell 5"),1,"Cell 6")
oItems:SetProperty("ExpandItem",h,.T.)
oForm:Show()
DO WHILE nEvent != xbeP_Quit
nEvent := AppEvent( @mp1, @mp2, @oXbp )
oXbp:handleEvent( nEvent, mp1, mp2 )
ENDDO
RETURN
|