|
<< Click to Display Table of Contents >> Navigation: Forum > How to read value changed of TIWBS4Dropdown |
06-01-2020, 02:05 PM:
no event fire.
-------------------------------
object IWForm12: TIWForm12
Left = 0
Top = 0
Width = 804
Height = 502
RenderInvisibleControls = True
AllowPageAccess = True
ConnectionMode = cmAny
Background.Fixed = False
LayoutMgr = IWBS4LayoutMgr1
HandleTabs = False
LeftToRight = True
LockUntilLoaded = True
LockOnSubmit = True
ShowHint = True
DesignLeft = 2
DesignTop = 2
object IWBS4Region1: TIWBS4Region
Left = 0
Top = 0
Width = 804
Height = 441
Align = alTop
Css = ''
HeightRender = True
Text = ''
WidthRender = False
BSRegionType = bs4rtContainer
object IWBS4DropDown1: TIWBS4DropDown
Left = 200
Top = 16
Width = 289
Height = 25
OnAsyncClick = IWBS4DropDown1AsyncClick
OnAsyncChange = IWBS4DropDown1AsyncChange
BSButtonSize = bs4bszLarge
IconOnRight = False
Caption = 'ITEMLIST'
DropDownItems = <
item
Caption = 'ITEM1'
end
item
Caption = 'ITEM2'
end
item
Caption = 'ITEM3'
end
item
Caption = 'ITEM4'
end
item
Caption = 'ITEM5'
end>
end
object IWBS4Label1: TIWBS4Label
Left = 200
Top = 64
Width = 281
Height = 25
Caption = 'No ItemName'
end
object IWBS4Text1: TIWBS4Text
Left = 80
Top = 112
Width = 657
Height = 305
end
end
object IWBS4LayoutMgr1: TIWBS4LayoutMgr
Left = 88
Top = 40
end
end
06-01-2020, 08:15 PM:
When you add items, you need to add an OnAsyncClick event to each item. I create 90+% of my IWBS4 components at run-time and here is how I add them in c++ (example):
TIWBS4DropDownItem * pDropDownItem=dynamic_cast<TIWBS4DropDownItem *> (CalendarNavigationMonthSelectDropDown->DropDownItems->Add());
pDropDownItem->Caption=FormatDateTime(L"mmmm yyyy",nDateStart);
pDropDownItem->Css= L" EventCalendarMonth";
pDropDownItem->OnAsyncClick=OnCalendarNavigationMonthSelectAsyncChange;
When the item is selected from the dropdown, the OnAsyncClick event is fired.
To get the index of the item selected in the event, do something like this:
void __fastcall TVTS3SelectEventCalendarForm::OnCalendarNavigationMonthSelectAsyncChange(TObject *Sender, TStringList *EventParams)
{
// Keep compiler happy
NOT_USED(Sender);
// Get selected month
intnSelectedMonth=EventParams->Values[L"itemidx"].ToIntDef(0);
...
}
Hope this helps!
Shane
06-02-2020, 02:55 PM:
Yes! Work fine. Thanks.
procedure TIWForm11.IWBS4DropDown1DropDownItems0AsyncClick(Sender: TObject;
EventParams: TStringList);
begin
IWBS4Text1.Lines.Assign(EventParams);
IWBS4Label1.Caption:= EventParams.Values['itemidx'];
end;