Board index » cppbuilder » Repeat (copy) focused field from previous record

Repeat (copy) focused field from previous record

In Delphi I have a routine that copies the currently  focused field from the
previous record that was entered before the current record. part of the code
is.
if  (activecontrol is tdbedit) then begin
  if  activecontrol.focused then
  fieldname:=(activecontrol as tdbedit).datafield;
Copyprevrecfield(fieldname);
this works in delphi. I don't know how to code the following line in
c++builder.
if (activecontrol is tdbedit)
I don't know what to substitute for the word ' is '.
I would appreciate any help ,thanks in advance
Sol
 

Re:Repeat (copy) focused field from previous record


Hello Sol,

s. lewin <s...@netvision.net.il> schreef in berichtnieuws
8mjul9$f...@bornews.borland.com...

Quote
> In Delphi I have a routine that copies the currently  focused field from
the
> previous record that was entered before the current record. part of the
code
> is.
> if  (activecontrol is tdbedit) then begin
>   if  activecontrol.focused then
>   fieldname:=(activecontrol as tdbedit).datafield;
> Copyprevrecfield(fieldname);
> this works in delphi. I don't know how to code the following line in
> c++builder.
> if (activecontrol is tdbedit)

Litterally the above would become:
    if( dynamic_cast<TDBEdit*>(ActiveControl) )

But since in your snippet there's also at least one cast involved e.g.
(activecontrol as tdbedit).datafield, I would go for the following:

TDBEdit *dbedit = dynamic_cast<TDBEdit*>(ActiveControl);
if( dbedit ) {
    if( dbedit->Focused() )
        FieldName = dbedit->DataField;
    ... // and what else you have to do here

Quote
}

Hope this helps...;-))

Quote
> Sol

--
Greetings from sunny Amsterdam

                Jan

email: bijs...@worldonline.nl
http://home.worldonline.nl/~bijster

Re:Repeat (copy) focused field from previous record


Jan
Thanks
Sol

Other Threads