int valueFromDB = 7
okCheckBox.Checked = ((valueFromDb And 1) = 1)
floodCheckBox.Checked = ((valueFromDb And 2) = 2)
And is a logical op. The result of (7 AND 2) is 2 because 2 is a common component of the sequences 4+2+1 and 2
7 AND 16 on the other hand, would return 0
7 AND 17 would return 1, because they only have 1 in common (4+2+1, 16+1)
So when decoding a numeric flags enum (using one of those would be even better than hardcoded constants - read up on them) like this, the logic is:
If totalValue AND flagValue = flagValue Then flag_is_set Else flag_is_not_set
-
you also have the option of having a HouseFlags table:
HouseID, Flag
1, OK
1, FP
1, Sq
2, FD
2, Su
2, Sq
And a table to decode the flag into a value (or just write the short text into the HouseFlags table.
In which case pushing data in and out of your table requires you to enumerate the flags and insert them one by one
-
If going the second route I'd ditch the checkboxes entirely and have a datagridview - this allows expansion
I'll post an example project as it will be easier than explaining