Solved

DBGrid Field value

Posted on 2006-11-01
9
1,249 Views
Last Modified: 2012-05-05
Dear Experts,

I have a DBGrid where Field2 value will depends on the Field1 value. If Field1 value change, the field2 value will change also. and the Field1 has picklist.

Can anybody tell me how to do it?

Thanks.
0
Comment
Question by:cmwong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 1

Expert Comment

by:ruanlab123
ID: 17855855
On the Field1 OnChange property, just set the value of field2 in the query your are using for your DBGrid.
0
 

Author Comment

by:cmwong
ID: 17856112
Dear ruanlab123,

Sorry, in the DBGrid field property don't have the onChange Property..
0
 
LVL 11

Expert Comment

by:calinutz
ID: 17856124
Write an onChange event for your DBGrid. Try the example found at this PAQ:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20842900.html

Cheers
:-)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:calinutz
ID: 17856130
Or, as suggested in the same PAQ, try using the OnColExit event and enter there the code for updating the dataset.
Regards
0
 
LVL 1

Expert Comment

by:ruanlab123
ID: 17856139
Sorry the DBGrid onChange event not property.
0
 
LVL 11

Expert Comment

by:Goodangel Matope
ID: 17856781
listening...
0
 

Author Comment

by:cmwong
ID: 17856936
Dear calinutz,

I am using the onChange event as you say, however the field is a picklist.. when i change the field1 value using the the picklist, the field2 value does change..but the field1 value remain the same.. I don't understand why?

Thanks.
0
 
LVL 11

Accepted Solution

by:
calinutz earned 250 total points
ID: 17859827
Another ideea would be to add all Fields of the Query or table that you use as DataSource. (Click on table and in Object  TreeView, select the query you use, right-click on the Fields and pick Add All Fields) And use the field's event OnSetText... or OnChange, or OnValidate... Try them all, at least one of them should work
I did not try them myself... so good luck. They all seem to do what you need. So in case of a change in a certain record field... do something... change the other field that you want to change.

regards
0
 
LVL 11

Expert Comment

by:calinutz
ID: 17864897
Why grade C?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question