Board index » delphi » Delphi-Disappearing component variables??

Delphi-Disappearing component variables??

Well, this is weird.. I have an app that uses a TTable and assorted components,
and after much misery, I discovered that whenever I use a Table.Insert call, all
the components lose their values inside that event handler -but only programatically,
not visually- for example, if a TTextbox says '123', you can see that displayed, but
the program just reads ''.
The de{*word*81} also sees only blanks.  This happens for TTextBox and TDBLookupCombo,
among others.  Remove the call to Table.Insert, and everything's fine again!
The visual DB controls are reading the table OK, so I don't think I have that part of it
messed up.

Any ideas?  This is driving me up the wall..

Enrique
eflo...@bangate.compaq.com

 

Re:Delphi-Disappearing component variables??


Quote
> Well, this is weird.. I have an app that uses a TTable and assorted components,
> and after much misery, I discovered that whenever I use a Table.Insert call, all
> the components lose their values inside that event handler -but only programatically,
> not visually- for example, if a TTextbox says '123', you can see that displayed, but
> the program just reads ''.
> The de{*word*81} also sees only blanks.  This happens for TTextBox and TDBLookupCombo,
> among others.  Remove the call to Table.Insert, and everything's fine again!
> The visual DB controls are reading the table OK, so I don't think I have that part of it
> messed up.

> Any ideas?  This is driving me up the wall..

> Enrique
> eflo...@bangate.compaq.com

If you are dealing with databound controls, the trick is to access the underlying TField
component instead of the edit control.
eg: TTable: MyTbl has column MyName visible with TDBEdit MyNameEdit
    access the data through TStringField: MyTblMyName.AsString instead
    of through  MyNameEdit.Text.

The cool thing is that no numeric/string conversions are nec and you have full access to
all the TTable columns even if they are not attached to a visual component.

David Hewick
dhew...@netaccess.on.ca

Other Threads