?
Solved

Extending vertical lines on a DBGrid

Posted on 2002-05-02
7
Medium Priority
?
312 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
[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
  • 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
Technology Partners: 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!

 

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 800 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

771 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