Class
WebToolbarContainer
Warning
This item was deprecated in version 2020r2. There is no replacement.
Description
A container control in a WebToolbar.
Properties
Name |
Type |
Read-Only |
Shared |
---|---|---|---|
Property descriptions
WebToolbarContainer.Badge
Badge As String
A small graphical element used to displayed additional information alongside the WebToolbarItem.
The text appears in white on a round rectangle with a red background.
WebToolbarContainer.Caption
Caption As String
The caption that appears in the control.
The Caption can be surrounded by "<raw></raw>" tags to temporarily disable HTML parsing. For example, you could bold just a single word in a Caption by doing this:
item.Caption = "<raw><b>bold</b></raw> text"
This code changes the caption for an existing container on the toolbar:
Var item As WebToolbarContainer
item = WebToolbarContainer(Toolbar1.ItemWithName("SearchControl"))
If item <> Nil Then
item.Caption = "New Caption"
End If
WebToolbarContainer.Container
Container As WebContainer
The ContainerControl that is assigned to the WebToolbarContainer. You can specify the container in the IDE at design time or in code.
This code changes the ContainerControl used by an existing container on the toolbar:
Var item As WebToolbarContainer
item = WebToolbarContainer(Toolbar1.ItemWithName("SearchControl"))
If item <> Nil Then
item.Container = New ContainerControl1
End If
WebToolbarContainer.Enabled
Enabled As Boolean
If True, the item can be pressed. If False, it cannot be.
WebToolbarContainer.Icon
Icon As WebPicture
The picture that is associated with the WebToolbarItem.
WebToolbarContainer.Size
Size As Integer
For vertical toolbars, Size is the height of the item. For horizontal toolbars, Size is the width of the item. The opposing dimension will always be dictated by the toolbar. For example, a horizontal toolbar which is 56 pixels tall, a container with a size of 200 inside it would have the dimensions 200 x 56.
This code changes the size for an existing container on the toolbar:
Var item As WebToolbarContainer
item = WebToolbarContainer(Toolbar1.ItemWithName("SearchControl"))
If item <> Nil Then
item.Size = 200
End If
WebToolbarContainer.Tag
Tag As Variant
A hidden value associated with the WebToolbarItem.
Since this is a Variant, this can be used to associate any type of data, even an object, with the WebToolbarItem.
WebToolbarContainer.Tooltip
Tooltip As String
A helpful message that describes the purpose of the WebToolbarItem.
WebToolbarContainer.Visible
Visible As Boolean
Indicates whether or not the WebToolbarItem is visible.
This property is useful when you need to hide/show WebToolbarItem's dynamically at runtime.
Notes
An important feature of the WebToolbarContainer is that it enables you to add controls other than buttons and menus to a WebToolbar. Create the container control and add it to the project; then assign it to the Container property of the WebToolbarContainer. The container will be resized to the dimensions of the item. When designing the container, be sure to set all lock properties appropriately.
In order for the container to access the page the toolbar is on, the container must have a property of type WebPage. It can be the actual page, for example WebPage1, or it can be just WebPage. However, if you use WebPage, you will need to typecast in order to get to the actual page. To set up the property, in the Open event of the Toolbar, you will need to cast the toolbar's container control as your original container control. See the example below.
Sample code
To add a search field to a toolbar, you first create a SearchFieldContainer by adding a WebSearchField to a ContainerControl.
On WebPage1, add a toolbar and then add a Container item to it (named "SearchControl"). Select it and enter "SearchFieldContainer" in the Target property field. You'll also want to change the Size property to 200.
Now run the app to see the SearchField in the toolbar.
Most of the time, the container will need to access the Web Page that contains it.
You can do this in the Open event handler for the toolbar that is on the web page. This code gets the WebToolbarContainer that is named "SearchField" on the toolbar and casts it to a SearchFieldContainer so that the ParentPage property (added to SearchFieldContainer: ParentPage As WebPage1) can be set to the web page (Self):
' Link the SearchField container control to the web page
Var search As WebToolbarContainer
search = WebToolbarContainer(Me.ItemWithName("SearchControl"))
Var searchField As SearchFieldContainer
searchField = SearchFieldContainer(search.Container)
searchField.ParentPage = Self
This can also be written more succinctly like this:
SearchFieldContainer(WebToolbarContainer(Me.ItemWithName("SearchControl")).Container).ParentPage = Self
With ParentPage property value now specified, you can have code on the SearchFieldContainer that uses it to access methods, properties or controls on the web page. This code in the WebSearchField.TextChanged event handler (on the SearchFieldContainer) adds search criteria to a ListBox on the web page when the user presses return/enter in the search field:
If ParentPage Is Nil Then Return ' Ensure that ParentPage was configured before using it
If Me.Text <> "" Then
' If the user typed something, then add it to the ListBox on the web page
ParentPage.RecentSearchesList.InsertRow(0, Me.Text)
End If
Compatibility
Web projects on all supported operating systems.
See also
WebToolbarItem parent class; WebMenuItem, WebToolbar, WebToolbarButton, WebToolbarFlexibleSpace, WebToolbarItem, WebToolbarMenu, WebToolbarSeparator, WebToolbarSpace classes.