WebMap for Blazor
  • WebMap Blazor
    • Modernization
      • Overview
      • Modernization Challenges
      • Our solution
      • What is Blazor?
      • How does Blazor Work?
      • Windows Forms in Blazor
      • Deployment
      • Interfacing with hardware devices
    • Research for Blazor
      • Handling Reference Parameters in Async Methods with Ref<T>
      • Alternatives to Async Properties in C#
      • Issue with using "MessageBox.Show" in Blazor
      • File Upload Functionality
      • Async/Await Feature for WebMap Blazor
    • Assessment Tool
    • Conversion Tool
      • Getting Started
      • Modals and Dialogs
      • Static Service Management
      • ImageListStreamer
      • Solution and Project Structure
        • Solution Generator
    • DCP: Desktop Compatibility Library
      • API Documentation
        • Blazor DCP: Gap.Blazor.Application Class Reference
      • Components Information
        • Button Component
        • Application Data Component
        • GroupBox Component
        • Label Component
        • CheckBox
        • CheckedListBox
        • ComboBox
        • DateTimePicker
        • Form
        • ListBox
        • ListView
          • WMListViewDetails
        • Mdi Container Component
        • MenuStrip
        • MessageBox
        • MonthCalendar
        • Panel
        • PictureBox
        • ProgressBar
        • RadioButton
        • StatusStrip
        • ToolStripStatusLabel
        • TabControl
        • TabPage
        • TextBox
        • ToolStrip
          • ToolStripButton
          • ToolStripLabel
          • ToolStripSeparator
        • ToolTip
    • Post Conversion
      • How To?
        • Create a new WebMap Window?
        • Create a new WebMap Component?
        • Create a native Blazor Window in a WebMap app?
        • Create a native Blazor Component in a WebMap Window?
        • Change the default WebMap visual layout?
    • WebMap: Angular vs Blazor
      • Footprint
      • Binaries size
      • Chatiness
      • Performance
      • Extensibility
      • Maintainability
      • Debugging
      • Project Structure
    • WebMap for Blazor Release Notes
      • Beta version
    • FAQ
    • Errors and Troubleshooting
    • License
Powered by GitBook
On this page
  • Description
  • Usage
  • Properties
  • Methods
  • Dynamic Rendering
  • Styles
  • Events
Export as PDF
  1. WebMap Blazor
  2. DCP: Desktop Compatibility Library
  3. Components Information

ComboBox

Description

This component represents a combo box in Blazor using the Gap.Blazor.ComboBox model. It utilizes the Telerik ComboBox component to provide a searchable, filterable dropdown list with support for custom values and dynamic styling.

Usage

@namespace Gap.Blazor.Components
@using Gap.Blazor
@using System.Collections
@using Telerik.Blazor.Components
@inherits WMControlComponentBase

@if (this.comboBox.Visible)
{
    <WMStyleBase model=@comboBox></WMStyleBase>
    <div class="@comboBox.GetStringClasses()" @onkeydown="@keyDownHandler">
        <TelerikRootComponent>
            <TelerikComboBox TValue="string"
                             TItem="object"
                             Data="@this.items"
                             Enabled="@this.Enabled"
                             AllowCustom="true"
                             Filterable="true"
                             ValueField="text"
                             TextField="value"
                             Width="100%"                                
                             @bind-Value="@this.Value" @ref="elementRef" TabIndex=@TabIndex>
                <NoDataTemplate>
                    <div>
                        <TelerikSvgIcon Icon="@SvgIcon.InfoCircle" Size="@ThemeConstants.SvgIcon.Size.Large" />
                        <br />
                        <br />
                        No items to display...
                    </div>
                </NoDataTemplate>
            </TelerikComboBox>
        </TelerikRootComponent>
    </div>

    <style>
        .@comboBox.GetComponentClass() .k-animation-container {
            top: @(comboBox.Height + "px") !important;
            left: 0px !important;
        }
        .@comboBox.GetComponentClass() .k-combobox {
            height: @(comboBox.Height + "px");
            font-size: inherit;
        }
        .@comboBox.GetComponentClass() .k-list-item {
            font-size: @comboBox.Font.GetFontSize();
        }
    </style>
}

Properties

  • ComboBox: Instance of the Gap.Blazor.ComboBox model.

  • ElementRef: Reference to the Telerik ComboBox component.

  • Items: A dynamically generated list of objects with text and value fields based on ListControlItems.

  • Value: Bound to the selected value in the combo box.

Methods

  • OnInitialized(): Subscribes to model events such as SelectedIndexChanged, SelectedValueChanged, ValueMemberChanged, DataSourceChanged, DisplayMemberChanged, DropDownStyleChanged, and Items.AfterAdd.

  • Focus(): Focuses the combo box using the elementRef.

Dynamic Rendering

The component dynamically renders a combo box based on the ComboBox model:

  • WMStyleBase: Applies styles based on the model.

  • TelerikComboBox: Provides the dropdown UI with filtering and custom value support.

  • NoDataTemplate: Displays a message when no items are available.

Styles

  • Dropdown Positioning: Adjusted using .k-animation-container.

  • Height and Font Size: Dynamically set based on the model.

  • List Item Styling: Font size is derived from the model’s font settings.

Events

  • SelectedIndexChanged

  • SelectedValueChanged

  • ValueMemberChanged

  • DataSourceChanged

  • DisplayMemberChanged

  • DropDownStyleChanged

  • Items.AfterAdd

PreviousCheckedListBoxNextDateTimePicker

Last updated 2 days ago