Solved

Default color change for the selected row

Posted on 2000-05-01
5
345 Views
Last Modified: 2010-04-04
How can I change the default color for the selected row (default is blue) in a TDbGrid control ?
0
Comment
Question by:drnadeem
  • 2
  • 2
5 Comments
 

Accepted Solution

by:
SuperSy earned 20 total points
ID: 2766857
Here's what you gotta do.

(1) Set the DBGrid's DeafultDrawing property to False.

(2) Make an OnDrawColumnCell event handler, and make it like this.

procedure TyForm.MyDBGridDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
begin
  // Turn TDBGrid.DefaultDrawing off (False) before doing all this
  if (gdSelected in State) then
    with Canvas do
    begin
      Brush.Color := clBlack; // Background color to Fill a Rectangle
      FillRect(Rect);         // Fill the whole cell
    end;
  // Draw things originally intended by Delphi
  MyDBGrid.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;

This should do for a selected cell or row when dgRowSelect is True.

And by the way, you might want to get rid of the other three duplicate questions before someone else answers them...
0
 
LVL 2

Expert Comment

by:mullet_attack
ID: 2768714
Too late !

I got in first, but I'll share the points with you, SuperSy ! :-)
0
 

Expert Comment

by:SuperSy
ID: 2770415
It would be nice if we can both get 20 points each...but I think ultimately it's up to drnadeem to decide upon whom he awards the points.  

I got my answer in before yours (11:41AM vs 10:30PM)...but your code is smaller and neater. If drnadeem thinks you win, so be it.  =)

Last thing I want is getting into one of those "I don't want points but I deserve some and it's your fault to begin with because blah blah blah" kind of war.  

I hope drnadeem got what s/he wanted.

SuperSy
0
 
LVL 2

Expert Comment

by:mullet_attack
ID: 2771430
I actually think your answer is better. It's the same as mine, however you gave a code example, whereas I did not. I also thought it humourous to 'fight' over 20 points.
:-))))
0
 
LVL 1

Author Comment

by:drnadeem
ID: 2944357
Answer accepted
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best Firemonkey component pack 1 119
Delphi cmd execution 6 67
Delphi: making a BW image transparent 10 60
Breakpoint doesn't stop in my variable 3 30
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

838 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