Solved

Extending vertical lines on a DBGrid

Posted on 2002-05-02
7
302 Views
Last Modified: 2010-08-05
Hello everyone,

I would like to have my DBGrid to have extended vertical gridlines until the bottom of the grid.

If you have for example only two records in a table, the column cells will be drawn only for those two records.  But it would be nicer to be able to extend the column delimiters vertically until the bottom of the grid.

Any ideas ?
0
Comment
Question by:fadyg
  • 3
  • 3
7 Comments
 
LVL 8

Expert Comment

by:Cesario
ID: 6986205
Do you have the source code of Unit DBGrids ?
0
 

Author Comment

by:fadyg
ID: 6986384
Yes, but I would not like to modify these sources but rather subclass DBGrid.  That way I can still beneficiate from any new feature in the next Delphi release..
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6986954
Two ways : 1. Add empty records or paint your lines ( simulate the empty records ) on procedure WMPAINT(var Message: TWMPaint); Message WM_Paint;
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:fadyg
ID: 6987974
I would go for the simulation of lines and not add records.  Do you have any piece of code that ?
0
 
LVL 9

Accepted Solution

by:
ginsonic earned 200 total points
ID: 6989517
This is a tip that I use it to make a flicker free DBGrid . How you can see, capture the grid image into Bitmap . Just paint your own's lines into the bitmap .

procedure WMPaint(var Message: TWMPaint);
var
  Bitmap: TBitmap;
  WinDC: HDC;
  PS: TPaintStruct;
  BegunPaint: Boolean;
begin
  BegunPaint := False;
  Bitmap := TBitmap.Create;
  try
    Bitmap.Width := Width;
    Bitmap.Height := Height;
    {Paint completely as normal, but into Bitmap}
    WinDC := Message.DC;
    Message.DC := Bitmap.Canvas.Handle;
    Inherited;
    {Need a Window DC ?}
    BegunPaint := WinDC = 0;
    if BegunPaint then
      WinDC := BeginPaint(Handle, PS);

      8<------
      Your code for paint lines
      -------->8      
 
      {Copy bitmap to screen}
      with Canvas.ClipRect do
        BitBlt(WinDC, Left, Top, Right - Left, Bottom - Top, Bitmap.Canvas.Handle, Left, Top, SRCCOPY);
  finally
    Bitmap.Free;
    if BegunPaint then
      EndPaint(Handle, PS);
  end;
end;
0
 

Author Comment

by:fadyg
ID: 6995829
The flicker part is really a good idea ;)
Drawing the lines will be just a matter of some canvas extra work (Moveto & Lineto) at the boundary of each column

thx
Fady
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6996544
My pleasure,
Nick
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

12 Experts available now in Live!

Get 1:1 Help Now