c# - Return ComboBox as Boolean -
i know not best practice use boolean combobox application returns data yes/no thats required. i'm trying return whether yes or no getting warning 'possible unintended reference' cleaning code appreciated.
public bool playdatatoend { { return this.playdatatoend.selectedvalue == "yes"; } set { this.playdatatoend.selectedvalue = true; } }
suppose internal combobox
named playdatatoendcombo
:
public bool playdatatoend { { return playdatatoendcombo.selectedvalue.tostring() == "yes"; } set { playdatatoendcombo.selectedvalue = value ? "yes" : "no"; } }
i think should use index
convention: 0 yes
, 1 no
:
public bool playdatatoend { { return playdatatoendcombo.selectedindex == 0; } set { playdatatoendcombo.selectedindex = value ? 0 : 1; } }
Comments
Post a Comment