locked
Databinding radiobuttons RRS feed

  • Question

  • Problem:

    My entity class contains a value, an int with the value 1,2 or 3. This is representet in the database as a tabel containing id and description. The easy choice would be databinding this table to a combobox, with selected to this value.

    But this is supposed to look like radiobuttons. My problem is databinding this value to radiobutton1/2/3.  Radiobutton1.checked if value=1, etc.

    Solutions could be to represent this value as three boolean in my entitclass. Dont wanna do that. Other solution is to set the three radiobuttons when _CurrentItemChanged, and set the value when eather of the buttons is changed. Dont wanna do that eather :-)

    Anyone done something slick for this sort of databinding?
    Thursday, November 10, 2005 7:43 AM

Answers

  • My solutionIdea: I made my own radiobutton control, which inherited from radiobutton, but added two properties, Value and ValueCausesChecked. I databind to Value, and design(or run-time) set which value that will cause the radiobutton to be true. Override the OnCheckedChanged.

    Works fine.

    Friday, November 11, 2005 9:05 AM