Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #101820
    xyzzy
    Member

    Hi,
    I am trying to use the ComboBox in Blazor and attach it to a DataSource.  The ComboBox only contains the  values “0”, “1” and “2” when I attach a List of three items, not the display values (or even values ) I was expecting.  Could you let me know what I am doing wrong?
    @if (cboGamma == null)
    {
    cboGamma = new List<comboitems>();
    comboitems blob;
    blob.label = “fred”;
    blob.value = 10;
    cboGamma.Add(blob);
    blob.label = “david”;
    blob.value = 11;
    cboGamma.Add(blob);
    blob.label = “norman”;
    blob.value = 12;
    cboGamma.Add(blob);
    }
    <ComboBox DataSource=”@cboGamma” DisplayMember=”label” ValueMember=”value” Style=”margin-left: 5px; width: 150px”></ComboBox>
    @code {
    struct comboitems
    {
    public string label;
    public int value;
    }
    List<comboitems> cboGamma;
    }

    #101821
    xyzzy
    Member

    Ok, figured this out – the typing needs to be a bit less…
    @if (cboGamma == null)
    {
    cboGamma = new List<object>()
    {
    new {label = “L*”, value = “0”},
    new {label = “sRGB”, value = “1”},
    new {label = “V”, value = “2”}
    };
    }
    List<object> cboGamma;
    How do I detect the OnChange event event properties?  I have:
    <ComboBox DataSource=”@cboGamma” OnChange=@cboGamma_Change DisplayMember=”label” ValueMember=”value” C Style=”margin-left: 5px; width: 80px”></ComboBox>
    @code{
    private void cboGamma_Change(Event eventObj)
    {
    ComboBoxItemClickEventDetail detail = eventObj[“Detail”];
    string label = detail.Label;
    int value = detail.Value;
    }
    But the eventObj[“Detail”] throws an error.  How do I get the Label and Value?
     

    #101822
    xyzzy
    Member

     
    Ok, figured that out too:
    ComboBoxChangeEventDetail detail = eventObj[“Detail”];
     

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.