Solved

DBGrid Onclick

Posted on 1997-11-13
5
530 Views
Last Modified: 2011-04-14
Since the DBGrid Object doesn't have an OnClick-Event,how do I know when it's clicked? And where?
PS. Can anybody help me on a book in which this sort of problem is dicussed? I'm getting tired of having to ask and bother you all the time,while there's some book with the solutions already in it!
0
Comment
Question by:lizzzard
  • 3
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
Pegasus100397 earned 50 total points
ID: 1350352
Lizzard,

Interesting question!

Try this in the Private declarations

procedure WMMouseActivate(VAR Msg)
    message WM_MOUSEACTIVATE

then

procedure TForm1.WM_MOUSEACTIVATE(Var Msg);
Begin
Form1.Caption := 'Mouse clicked!';
end;

you could expand this to indicate which control sent the click but it works well on my dbGrid :)

One of the best books for offbeat, strange Delphi solutions is:
DELPHI PROGRAMMING PROBLEM SOLVER
by Neil Rubenking
ISBN #1-56884-795-5

Good luck with your project!
Pegasus

0
 

Author Comment

by:lizzzard
ID: 1350353
Dear Pegasus,

Thanks for your answer and I almost got it working except for on e thing..:)
The click on the dbgrid is to check or uncheck a checkbox that is on it. In order to write the code for updating the physical field and the checkboxdrawing I'll have to know what column was clicked. If I try to use dbgrid.selectedfield.fieldname it's always 1 click behind on the Tform.WM_MOUSEACTIVATE event you suggested,so in the code fired by the click I still don't know wether or not to update the field. Or have I done this al wrong in the first place? Please help me...

Regards Lizzzard (alexg@molyvos.net)
0
 
LVL 3

Expert Comment

by:Pegasus100397
ID: 1350354
Lizzzard,

Sorry for the long time to reply, I've been out with the flu for a week or two. Look in the Win32s help file for the WM_MOUSEACTIVATE keyword and it will show you how to determine not only what the mouse action was, but WHO (or what in this case, like a column) actually sent the click message. If you get into a bind or can't understand it lemme know and I'll hunt down some examples.

By the way, why do the checkboxes in the grid NOT work? They should work by default unless the column is disabled or marked as read-only. Let me know

Thanks & good luck!
Pegasus
0
 

Author Comment

by:lizzzard
ID: 1350355
Hi Pegasus,

Hope you're better now (lots of orangejuice?). Thanks for your comment. I managed to get it working and it works great!
I only programmed 4GL till a vew months ago, Then I started with Delphi and at first I was hopelessly lost in 3GL language. But now things start to work out and I really enjoy programming Delphi.
Thanks for all the good advices!

Lizzzard
0
 
LVL 3

Expert Comment

by:Pegasus100397
ID: 1350356
Heya Lizzzard,

Glad to hear the problem is solved! Also glad to hear you *started* programming in Delphi instead of a real-language wanna-be like Visual Basis hehehaha Everything you learn with Delphi will only lead you to be utterly dissappointed with the limitations of other languages ;^D

Pegasus
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Working this component WebCopy with proxy, help 3 84
FMX StringGrid1->Canvas->FillRect Problem 3 150
Delphi - replicating a form 8 72
Print Graphic and Text to Epson TM-T88v 12 241
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

813 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now