I've set ValueChecked and ValueUnChecked to True / False respectively.
When using TNextDBGrid and TNxDBCheckBoxColumn an exception is thrown when clicking the checkbox. The method TNxDBCheckBoxColumn.ApplyField attempts to cast a True/False string Value using StrToBool. However, StrToBool, at least in Delphi 6 is raising an exception even though TrueBoolStrs contains 'True'.
Here is my work-around for that.
procedure TNxDBCheckBoxColumn.ApplyField(Value: WideString); var B: Boolean; begin TryStrToBool(Value, <img src='http://www.bergsoft.net/forum/public/style_emoticons/<#EMO_DIR#>/cool.png' class='bbc_emoticon' alt='B)' />; case B of True: if FField.DataType = ftBoolean then FField.AsBoolean := True else FField.Text := ValueChecked; False: if FField.DataType = ftBoolean then FField.AsBoolean := False else FField.Text := ValueUnchecked; end; end;
When the grid is loaded and a TNxDBCheckBoxColumn is present in a column the checkbox isn't painted until the column (even though the checkbox isn't visible) is clicked at least once. After doing so the ValueChecked and ValueUnChecked text values are assigned. The checkbox isn't painted since the text value is an empty string.
Here is my work around for this, which uses the DefaultValue to represent a False condition. The column's DefaultValue must be empty.
procedure TNxDBCheckBoxColumnDisplay.Paint; var Value: Boolean; begin with Column as TNxDBCheckBoxColumn do begin if WideSameText(AsString, ValueChecked) then Value := True else if WideSameText(AsString, ValueUnchecked) then Value := False else if WideSameText(AsString, DefaultValue) then Value := False else Exit; DrawCheckBoxState(Self.ClientRect, Value, False, False); end; end;