Member variable XbpCombobox():visualStyle Foundation

Specifies the visual style to use for displaying items.

Attribute: EXPORTED
Data type: Object (NIL)
Description

The default representation used for displaying the items in a combo box object can be overridden using the :visualStyleinstance variable. To do this, an instance of the XbpHTMLStyle() class must be assigned to :visualStyle, which is then used to draw the items.

HTML style objects use HTML markup and optional CSS style sheets to create the visual representation of each item. For this, the item's HTML markup must be specified in the <cItem>parameter when calling :addItem(). In addition, if a CSS style sheet is to be used, the CSS must be supplied when instantiating the XbpHTMLStyle object.

The following code snippet shows the basic steps required for using a custom visual style with an XbpCombobox object.

(...) 
// 
// Define the representation of 
// the combo box items via CSS. 
// Note that dedicated styling 
// is defined for the combo edit 
// element and the item's 
// "selected" state. 
// 
TEXT INTO cCSS WRAP 
 <style> 
  .item { 
     font-size: 15px; 
     color: #232323; 
     height: 100%; 
  } 
  .item.comboboxedit { 
     font-size: 0.8em; 
  } 
  .item:active { 
     color: white; 
     background-color: blue; 
  } 
 </style> 
ENDTEXT 

// 
// Create the HTML style object 
// and assign the styling defined 
// via CSS. 
// 
oStyle := XbpHTMLStyle():New( cCSS ) 
oStyle:MinHeight := 52 

// 
// Create the combo box object 
// and assign the HTML style 
// 
oCb := XbpComboBox():New( oParent ) 
oCb:VisualStyle := oStyle 
oCb:Type := XBPCOMBO_DROPDOWNLIST 
oCb:Create( ,, {50,80}, {300,230} ) 

// 
// Add two items to the combo box. 
// The item content is defined in 
// the HTML markup, the visual 
// representation is defined in the 
// CSS 
// 
oCb:AddItem( [<div class="item">Item #1</div>] ) 
oCb:AddItem( [<div class="item">Item #2</div>] ) 
(...) 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.