@using System.Windows.Forms
@inherits ListBoxBaseComponent<ListBoxControl>

<select style="@GetStyle"
        name="@Control.Name"
        size="@Control.Items.Count"
        multiple="@(Control.SelectionMode == SelectionMode.MultiSimple
                    || Control.SelectionMode == SelectionMode.MultiExtended)"
        disabled="@IsDisabled">
    @for (int i = 0; i < Control.Items.Count; i++)
    {
        int index = i;
        <option selected="@(index == Control.SelectedIndex)"
                @onclick="() => SelectChanged(index)">
            @Control.Items[index]
        </option>
    }
</select>

@code { 

    private void SelectChanged(int index)
    {
        Control.SelectedIndex = index;
        ListBoxChange();

        Refresh();
    }

    protected override void OnParametersSet()
    {
        FillData();
        // before or after ?
        Control.FilterData();
    }

    private void ListBoxChange()
    {
        ControlFilterRefresh();
        Control.OnSelectedIndexChanged(null);
    }
}
