Delphi Clinic C++Builder Gate Training & Consultancy Delphi Notes Weblog Dr.Bob's Webshop
Bob Swart (aka Drs.Bob) Dr.Bob's Delphi Clinics Dr.Bob's Delphi Courseware Manuals
View Bob Swart's profile on LinkedIn Drs.Bob's Delphi Notes
These are the voyages using Delphi Enterprise (and Architect). Its mission: to explore strange, new worlds. To design and build new applications. To boldly go...
Title:

Moving to Delphi 2010, TDBGrid and Title Clicks

Author: Bob Swart
Posted: 12/9/2009 11:33:05 AM (GMT+1)
Content:

Delphi 2010 introduces theming for the TDBGrid control, using the DrawingStyle property (which can be gdsThemed (default), gdsClassic or gdsGradient) and introducing GradientStartColor and GradientEndColor for the latter.

It's not the only change made to the TDBGrid control, unfortunately. New are also the dgTitleClick and dbTitleHotTrack flags in the Options property. And although there's no documentation for them in the help (yet), it's pretty obvious what they do. Specifically, setting the dgTitleClick flag in the Options property will ensure that the OnTitleClick event handler is called (when assigned) when someone clicks on the title.

Their intended meaning isn't the issue here. And when you place a new TDBGrid component on a form, the options dgTitleClick and dbTitleHotTrack are included in the Options property by default. However... when you take an existing VCL forms application, and open it up with Delphi 2010, then these previously unknown Option flags will not be in the DFM file, so they will not be set, and hence dgTitleClick and dgTitleHotTrack will be false. And as a surprise the OnTitleClick event handler is no longer called. Simply by recompiling an existing Delphi VCL application in Delphi 2010. Ouch!

So, if you or your customers suddenly find that clicking on TDBGrid titles no longer works, check the dgTitleClick flag of the Options property (of all your TDBGrids).

Back  


7 Comments

AuthorPostedComments
John 09/12/09 16:42:55Nice catch. We'll be migrating our apps pretty soon, and thanks to you this issue is now preemptively handled. grd->Options = TDBGridOptions() << dgTitles << dgColumnResize << ... #if (__BORLANDC__ >= 0x0620) << dgTitleClick // RAD2010 #endif dgRowLines << dgTabs << dgRowSelect << dgConfirmDelete << dgCancelOnExit;
Bob Swart 09/12/09 17:18:42I'm glad I could save you some time - it took me a little while (and frustration) to figure it out... Fortunately, I was testing it on my own, and no "innocent" clients were harmed in the process ;-)
Bryan Smith 10/04/12 17:19:49Thanks for helping with the Gotcha about the dgTitleClick option. When I saw the event wasn't being called, I searched the web, and found your post and it saved me alot of time, with my users waiting. Any idea why the TDBGrid.Columns[].Title.Color property is not working?
Peter 11/03/25 06:57:14Man I've been pulling my hair out over this one. Nice one. By default Embarcadero left it set off. Thanks a bunch.
Erwin Mouthaan 12/08/14 16:14:29Thanks! I have just migrated for customer a Delphi 2006 project to Delphi XE2, when I thought by myself: was there not an issue with option dgTitleClick for TDBGrid control. I thought I had read that somewhere....
Bob Swart 12/08/14 16:20:04Indeed you did - glad you found it ;-)
Thomas Riedel 13/08/28 17:33:39Thanks it saved me for a lot of time


New Comment (max. 2048 characters, no HTML):

Name:
Comment:



This webpage © 2005-2014 by Bob Swart (aka Dr.Bob - www.drbob42.com). All Rights Reserved.