BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Cannot attach OnValidate event to TField

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (Desktop)
View previous topic :: View next topic  
Author Message
Ulrich
Guest





PostPosted: Fri Oct 15, 2004 1:40 pm    Post subject: Cannot attach OnValidate event to TField Reply with quote



I have been trying to find a way of validating data input into a DBGrid
before it updates the database. It seems the best way is to use the
OnValidate event on the fields I want to validate.

My problem is that I cannot find a way of attaching the event to the
table. Double-clicking on the DBGrid shows the Columns of the database.
When I select a field I can see its properties in the object inspector,
but the events tab is blank.
Why is OnValidate not in the events tab?

Any ideas are appreciated.
Back to top
Jayme Jeffman Filho
Guest





PostPosted: Fri Oct 15, 2004 2:14 pm    Post subject: Re: Cannot attach OnValidate event to TField Reply with quote



Hello Ulrich,

Have you considered creating persistent fields on your data set ?

HTH

Jayme.

"Ulrich" <uw27 (AT) freenet (DOT) de> escreveu na mensagem
news:416fd331 (AT) newsgroups (DOT) borland.com...
Quote:
I have been trying to find a way of validating data input into a DBGrid
before it updates the database. It seems the best way is to use the
OnValidate event on the fields I want to validate.

My problem is that I cannot find a way of attaching the event to the
table. Double-clicking on the DBGrid shows the Columns of the database.
When I select a field I can see its properties in the object inspector,
but the events tab is blank.
Why is OnValidate not in the events tab?

Any ideas are appreciated.



Back to top
Ulrich
Guest





PostPosted: Fri Oct 15, 2004 3:35 pm    Post subject: Re: Cannot attach OnValidate event to TField Reply with quote



Hello Jayme,

thanks for your reply.
What do you mean, create persistent fields on the data set?
The database has several persistent fields, so the data set
has persistent fields. Or am I wrong?

Ulrich



Jayme Jeffman Filho wrote:
Quote:
Hello Ulrich,

Have you considered creating persistent fields on your data set ?

HTH

Jayme.

"Ulrich" <uw27 (AT) freenet (DOT) de> escreveu na mensagem
news:416fd331 (AT) newsgroups (DOT) borland.com...

I have been trying to find a way of validating data input into a DBGrid
before it updates the database. It seems the best way is to use the
OnValidate event on the fields I want to validate.

My problem is that I cannot find a way of attaching the event to the
table. Double-clicking on the DBGrid shows the Columns of the database.
When I select a field I can see its properties in the object inspector,
but the events tab is blank.
Why is OnValidate not in the events tab?

Any ideas are appreciated.




Back to top
Jayme Jeffman Filho
Guest





PostPosted: Fri Oct 15, 2004 3:45 pm    Post subject: Re: Cannot attach OnValidate event to TField Reply with quote

Hello Ulrich,

We call persistent fields those which are created when
you right click a TDataSet component like TQuery or
TTable and click on the "Fields Editor" option and ask
to add all fields. The TDataSet::Database must be
connected.

This action creates the TFields you've asked to, adding
their definition on the header file of the form that contains
the TDataSet component.

HTH

Jayme.

"Ulrich" <uw27 (AT) freenet (DOT) de> escreveu na mensagem
news:416fee22$1 (AT) newsgroups (DOT) borland.com...
Quote:
Hello Jayme,

thanks for your reply.
What do you mean, create persistent fields on the data set?
The database has several persistent fields, so the data set
has persistent fields. Or am I wrong?

Ulrich



Jayme Jeffman Filho wrote:
Hello Ulrich,

Have you considered creating persistent fields on your data set ?

HTH

Jayme.

"Ulrich" <uw27 (AT) freenet (DOT) de> escreveu na mensagem
news:416fd331 (AT) newsgroups (DOT) borland.com...

I have been trying to find a way of validating data input into a DBGrid
before it updates the database. It seems the best way is to use the
OnValidate event on the fields I want to validate.

My problem is that I cannot find a way of attaching the event to the
table. Double-clicking on the DBGrid shows the Columns of the database.
When I select a field I can see its properties in the object inspector,
but the events tab is blank.
Why is OnValidate not in the events tab?

Any ideas are appreciated.






Back to top
Ulrich
Guest





PostPosted: Wed Oct 20, 2004 11:41 am    Post subject: Re: Cannot attach OnValidate event to TField Reply with quote

Hello,

thanks so far for your help. I managed to attatch the OnValidate-Event
to all TFields.

But now I have another problem: In my program it is possible to add an
new field dynamicly at runtime. I do this by executing an SQL-statement.
Up to now the new field was shown in the DBGrid and was editable. Now
the field is not shown in the DBGrid. And when I try to set a value (
for example: DataSet->FindField(name)->Text = "a" ) there is always an
error, because the field can not be found.

I have another question. After solving the upper problem, how can I
attatch the OnValidate-Event to the new added field dynamicly at runtime?

Thanks for any solutions.

Ulrich



Jayme Jeffman Filho wrote:
Quote:
Hello Ulrich,

We call persistent fields those which are created when
you right click a TDataSet component like TQuery or
TTable and click on the "Fields Editor" option and ask
to add all fields. The TDataSet::Database must be
connected.

This action creates the TFields you've asked to, adding
their definition on the header file of the form that contains
the TDataSet component.

HTH

Jayme.


Back to top
Jayme Jeffman Filho
Guest





PostPosted: Wed Oct 20, 2004 12:33 pm    Post subject: Re: Cannot attach OnValidate event to TField Reply with quote

Hello Ulrich,

From the Help file : "When you create persistent fields for
a dataset, only those fields you select are available to your
application at design time and runtime."

I don't know how to create persistent fields at runtime. So
I think you should not use persistent fields if your application
needs to add fields to the data set at runtime. So delete all
persistent fields you've created, I'm sorry.

There are other ways of getting access to the TField object :
1. TFielld *aField = DataSet->Fields->Fiels[i] ;
// where i is the field order in the data set.
2. TFielld *aField = DBGrid->Fields[i] ;
// where i is the column order in the DBGrid.

Setting aField->ReadOnly = true has the same result that
you've got using persistent fields.

You can set any event handler by setting it to the name of
the function which is intend to be a event handler

void myFunction (TField *Sender);
aField->OnValidate = myFunction ;

HTH

Jayme.

"Ulrich" <uw27 (AT) freenet (DOT) de> escreveu na mensagem
news:41764ed6$1 (AT) newsgroups (DOT) borland.com...
Quote:
Hello,

thanks so far for your help. I managed to attatch the OnValidate-Event
to all TFields.

But now I have another problem: In my program it is possible to add an
new field dynamicly at runtime. I do this by executing an SQL-statement.
Up to now the new field was shown in the DBGrid and was editable. Now
the field is not shown in the DBGrid. And when I try to set a value

for example: DataSet->FindField(name)->Text = "a" ) there is always an
error, because the field can not be found.

I have another question. After solving the upper problem, how can I
attatch the OnValidate-Event to the new added field dynamicly at runtime?

Thanks for any solutions.

Ulrich



Jayme Jeffman Filho wrote:
Hello Ulrich,

We call persistent fields those which are created when
you right click a TDataSet component like TQuery or
TTable and click on the "Fields Editor" option and ask
to add all fields. The TDataSet::Database must be
connected.

This action creates the TFields you've asked to, adding
their definition on the header file of the form that contains
the TDataSet component.

HTH

Jayme.




Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (Desktop) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.