<ListBox>

The Listbox tag renders as a single or multi-select listbox at run-time.

Syntax

<ListBox
    AccessKey="string"
    AppendDataBoundItems="True|False"
    BackColor="color name|#dddddd"
    BorderColor="color name|#dddddd"
    BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge| Inset|Outset"
    BorderWidth="size"
    CssClass="string"
    DataField="string"
    DataSourceID="string"
    DataTextField="string"
    DataTextFormatString="string"
    DataType="string|int32|...."
    DataValueField="string"
    Font-Bold="True|False"
    Font-Italic="True|False"
    Font-Names="string"
    Font-Overline="True|False"
    Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium| Large|X-Large|XX-Large"
    Font-Strikeout="True|False"
    Font-Underline="True|False"
    ForeColor="color name|#dddddd"
    Height="size"
    ID="string"
    Rows="integer"
    SelectedItemsSeparator="string||"
    SelectionMode="Single|Multiple"
    Style="string"
    TabIndex="integer"
    ToolTip="string"
    Visible="True|False"
    Width="size">


    <ListItem value="string" selected="True|False">Item1</ListItem>
    <ListItem value="string">Item2</ListItem>
    ...
</ListBox>

Remarks

Back to top

Example

<addform>
  ...
  <table>
    <tr>
       <td>
        <label for="txtFirstName" text="First Name" />
        <textbox id="txtFirstName" datafield="FirstName" datatype="string" />
      </td>
    </tr>
    <tr>
      <td>
        <label for="lstColors" text="Favorite Color" />
        <listbox id="lstColors" datafield="FavoriteColors" datatype="string" selectionmode="single">
          <listitem value="#00FF00">Green</listitem>
          <listitem value="#FF0000" selected="true">Red</listitem>
          <listitem value="#0000FF">Blue</listitem>
         </listbox>

      </td>
    </tr>
    <tr>
      <td colspan="2">
        <addbutton text="Add"/> <cancelbutton text="Cancel"/>
      </td>
    </tr>
  </table>
</addform>
 

Example 2 - Binding to a Data Source

<AddForm>
  ...
  <ControlDataSource Id="dsColors" CommandText="SELECT ColorId, ColorName FROM MyColorsTable"/>
  ...
  <ListBox Id="lstColors" DataSourceId="dsColors" DataTextField="ColorName" DataValueField="ColorId"
     DataField="FavoriteColor" DataType="Int32" />
</AddForm>

Example 3 - Adding Items to a Data-Bound List

This example shows how to use the AppendDataBoundItems property to add a "None Selected" item to a list that is being populated from a table.

<AddForm>
  ...
  <ControlDataSource Id="dsColors" CommandText="SELECT ColorId, ColorName FROM MyColorsTable"/>
  ...
  <ListBox Id="lstColors" DataSourceId="dsColors" DataTextField="ColorName" DataValueField="ColorId"
     DataField="FavoriteColor" DataType="Int32" AppendDataBoundItems="True">
    <ListItem Value="-1">(None Selected)</ListItem>
  </ListBox>
</AddForm>

 

Back to top