Jump to content


spongebob

Member Since 03 Apr 2008
Offline Last Active Apr 24 2014 12:37 PM
-----

Topics I've Started

Checkbox will not get checked : TNxDBcheckBoxColumn.ApplyField broken ?

22 April 2009 - 02:42 PM

TNxDBGrids with checkboxes do not work for me any more, starting with V4.1.9.1 - this seems to be a localization issue (Germany):

My Problem is : the checkbox will not get checked when clicking an empty checkbox.

My settings for the tNXDBCheckBox-column:

myDBCheckBoxColumn.ValueChecked = 'Wahr'; // myBoolfield.asString = 'Wahr', if myBoolField.Value = true
myDBCheckBoxColumn.ValueUnchecked = 'Falsch'; // myBoolfield.asString = 'Falsch', if myBoolField.Value = false

When clicking the checkbox, the procedure TNxDBCheckBoxColumn.ApplyField is called with Value = 'True'. This 'True' comes from the BooltoStr() - call in tNextDBGrid.DoColumnPlayChange.

CODE
procedure TNxDBCheckBoxColumn.ApplyField(Value: WideString);
var
  B: Boolean;
begin
  if ValueChecked = '' then
    B := StrToBool(Value)
  else begin
    B := WideSameText(ValueChecked, Value); // !!!!! B is always false, because 'True' <> ValueChecked ('Wahr') !!!!!
  end;

  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;


Does tNxDBCheckboxColumn work for anyone in Germany / anyone not using english locale settings ?
Or am I missing something ?

In a previous version of TNxDBCheckBox, Applyfield looked like this :

CODE
procedure TNxDBCheckBoxColumn.ApplyField(Value: WideString);
begin
  case StrToBool(Value) of
    True: FField.Text := ValueChecked;
    False: FField.Text := ValueUnchecked;
  end;
end;


This worked nice, but I guess Boki had a reason to change it. Here's my temporary workaround for tNXDBCheckBoxColumn.ApplyField:

CODE
  //if ValueChecked = '' then
    B := StrToBool(Value)
  //else begin
  //  B := WideSameText(ValueChecked, Value);
  //end;

  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;


Boki, can you please review tNXDBCheckBoxColumn.ApplyField ?

Thank you very much !!!






Problem with TNxComboBoxItem + Cursor key (Bug)

25 March 2009 - 05:13 PM

If a TNXComboBoxItem is the last Child node in an Inspector, pressing the key "cursor down" modifies the combobox value and the modification is not consistent.
  • The displayed value is changed
  • The value of the Item changes to a different value after activating it again

I attached a small demo - here are my instructions to show the problem
  • Start Inspectorproblem1.exe
  • Press cursor down and keep cursor down pressed
  • Value of the last childitem (combobox) will change to "Comboline5" if you keep cursor down pressed long enough
  • Click on Item 5
  • Click on the last ComboBox Item again (or scroll down to it)
  • ComboBox Value changes to "Comboline1" magically ohmy.gif
  • Finally : scroll up to the first Combobox Item. This combobox does not change the value with the cursor key !

I think this behaviour is not desirable. Why does cursor down change the value of the combobox if it is the last childItem ? I do not want the cursor keys to change combobox Values at all.
(My users can easily screw up the program configuration by pressing cursor down in the Inspector if it behaves this way !)

Any ideas anyone ? How do you prevent this from happening ?

Thanks for your help !!!