Jump to content


m610

Member Since 09 Jun 2008
Offline Last Active Mar 10 2016 07:39 PM
-----

Topics I've Started

Problem with TNxEdit and TextAfter

10 March 2016 - 04:06 AM

These are two separate problems.

 

1. TextAfter

I discovered a while back that with TNxNumberEdit if I use text containing a period in the TextAfter property that an error is produced. It's been a while, so I forget exactly the error, but it is probably a conversion problem. For example, "sec" is OK, but 'sec." is not.

 

2. TNxEdit

I group the responses to the OnChange and OnSelect events of various editors into one procedure. With so many editors in a form I find this helpful. I use the editor's TAG property and (Sender is .. ) to match the editor with what needs to be done.

 

I'll attach the full code that I am using, but will include a summary here.

 

Procedure SomethingChanged(Sender:TObject);

var Idx: integer;

var iValue: integer;

var fValue: single;

begin

 

  Idx:=(Sender as TComponent).tag;

 

// I use Idx, iValue, fValue for my typing/reading convenience.

 

// I'm using TNxComboBox to get various types of values from the user, including text and the item index.

if (Sender is TNxComboBox) then

begin

  iValue:= (Sender as TNxComboBox).ItemIndex;

  case IDX of

    1: X:= iValue;

    2: Y:= (Sender as TNxComboBox).Items[iValue];

  end;

end;

 

// I'm using TNxEdit to get numbers from the user. I needed to be able to use exponential notation for these numbers.

if (Sender is TNxEdit) then

begin

  fValue:= StrToFloat(Sender as TNxEdit).AsFloat;

  case IDX of

    3: S:= fValue;

    4: T:= fValue;

  end;

end;

 

// Here of course I am getting only numbers from the user.

if (Sender is TNxComboBox) then

begin

  fValue:= (Sender as TNxNmberEdit).AsFloat;

  case IDX of

    1: A:= fValue;

    2: B:= fValue;

  end;

end;

 

end;

 

The problem here is that whenever the Sender is a TNxComboBox or TNxEditBox the section meant to handle the TNxEdit events is used. For example, after going through the part meant for TNxComboBox, the TNxEdit code is also executed. The same occurs when the Sender is a TNxNumberEdit component. It's as if TNxEdit is also a TNxComboBox and TNxNumberEdit. The way I have written the code here StrToFloat fails when the text is not a number or if it is a number and includes a TextAfter string.

 

The workaround is easy enough, but figuring this out took me a lot of time. I figured you might like to know about it and fix it.

 

Mike


Error closing form when editing a cell

04 January 2016 - 04:39 AM

Hi,

I have a grid in component which is in a form and I am having trouble when I close the form, but only if the grid cell was being edited and only if I close the form by clicking the X in the header. Clicking my "Close" button does not cause this error.

 

The access violation error occurs in:

 

function TNxCustomGridControl.ApplyEditing: Boolean;
var
    Accept: Boolean;
  Value: WideString;
begin
  Result := False;
  if (gtEdit in GridState) then
    begin
      Accept := True;
    { 9/7/07: Spin edit need to adjust bounds on editing done }
    FInplaceEdit.ApplyEditing;
    Value := FInplaceEdit.Text;

    Columns[FEditingCell.X].ApplyEditing(Value);
.

.

 

The editor highlights the last line, so the Value:=... line was probably the problem.

.

If in my component's  Desctructor routine I place Grid.EndEditting before Grid.Free I get a different access violation, this time in:

 

function TNxColumns.GetCount: Integer;
begin
  Result := FItemsList.Count;
end;
 

 

Here's my destructor routine.

 

destructor TGST_Panel.Destroy;
begin
  CyclesLbl.Free;
  CyclesValueLbl.Free;
  CyclesSE.Free;
  CycleTimeLbl.Free;
  Cycle_TimeLbl.Free;
  TotalTimeLbl.Free;
  Total_TimeLbl.Free;
  Option1Pnl.Free;
  StartTempLbl.Free;
  StartTempValueLbl.Free;
  StartTempEdit.Free;
  Option2Pnl.Free;

  Grid.EndEditing;
  Grid.Free;

  inherited Destroy;
end;

I tried moving the grid line to the top, figuring maybe a component that had just been freed was being accessed, but that did not help.

 

Is there a way to cancel the edit rather than end it? Or is there something else I should try?

 

Thanks,

Mike

 

Edit -- I moved the EndEditting line to the OnCloseQuery routine in the form and I still get the error in   Result := FItemsList.Count;


Copy/Paste to/from Excel

12 August 2015 - 12:47 AM

Is it possible to copy and paste cells to and from Excel and TNxGrid? I just need to copy/paste the values, not formulas.

 

Thanks,

Mike