0
votes

I have a combobox which datasource is custom class list. I have a model class which has different type of property.

function List<CmbItems<string, bool>> getTrueFalses()
{
    return new List<CmbItems<string, bool>>
    {
        new CmbItems<string, bool> { DisplayName = "Y", Value = true },
        new CmbItems<string, bool> { DisplayName = "N", Value = false }
    };
}

I am using this in combobox(cmbMarried) datasource property. User DisplayName property as DisplayMember and Value property as ValueMember.

I have other Model Class User. Which has property isMarried. Now i want to bind in combobox to that databinding.

How can i do that?

1
Are you using Windows Forms or WPF? - er-sho
windows form app - Naitik Kundalia
did u try to get like this => user.IsMarried = Convert.ToBoolean(cmbBox.SelectedValue) ? - er-sho
I want to use databinding because i used in textbox. Form is very huge, so databinding is helpful, else i know how to set in model - Naitik Kundalia
I added my answer below try it and let me know :) - er-sho

1 Answers

0
votes

There is casting issue in databinding. That's why databinding is not working and i put question here because i thought databinding and datasource not working simultanously.