Board index » cppbuilder » TDBGrid Title drawing ?

TDBGrid Title drawing ?


2007-02-12 04:03:51 PM
cppbuilder31
Hello,
I want draw a bitmap on DBGrid Title like OutLook Express for change sort
direction ASC, DESC
How can do it ?
Best Reagrds,
 
 

Re:TDBGrid Title drawing ?

Hay Sasan,
The OnTitleClick event of the DBGrid provides you access to the undying
TColumn, which (obviously) provides access to the individual columns on the
grid. The TColumn has an ImageIndex property which can be used to get an
image from a TImageList.
If you add an image list to your form and add in to glyphs to the list to
represent the up and down arrows, you can then assign either of these to the
column to indicate sort order. The code snippet below is on that i use for
TListViews but is should be applicable to a DBGrid if added to the
OnTitleClick even.
The arrows aren't positioned in the same place as in explorer or outlook but
it looks ok. I would personally not use the DBGrid (or any data aware
VCL's) preferring instead to propagate a listview from the undying data
source - but that is personal preference.
HTH, Mike C
// ListView ColumnClick or DBGrid TitleClick...
lvwListOptions->Items->BeginUpdate();
try
{
// Sort might not be accessible or implimented in DBGrid...
/lvwListOptions->CustomSort(NULL, Column->Index);
// Clear any existing arrow images
for (int i=0; i<lvwListOptions->Columns->Count; ++i)
{
lvwListOptions->Columns->Items[i]->ImageIndex = -1;
}
// Draw Up or Down arrow
if (Asending) // You have to determine this yourself - i store it in a
bool value
Column->ImageIndex = (lvwListOptions->SmallImages->Count - 2);
else
Column->ImageIndex = (lvwListOptions->SmallImages->Count - 1);
}
__finally
{
lvwListOptions->Items->EndUpdate();
}
"Sasan" < XXXX@XXXXX.COM >wrote in message
Quote
Hello,

I want draw a bitmap on DBGrid Title like OutLook Express for change sort
direction ASC, DESC

How can do it ?

Best Reagrds,