Solved

Color the colom of the selected cell

Posted on 2004-09-17
6
284 Views
Last Modified: 2010-04-05
A good morning to you all.

I have a string grid, with data in it.
Has 6 rows and 3 colums. Want I need to be able to do is color the colum that has the selected cell. So, If the click on a cell in coloum 2 that whole colums color becomes dark blue. Or if they selected a cell in coloum 1 that whole colums color would go dark blue.

Basically, it's getting the selected cells coloum and using that on the ondraw event - shouldn't be to hard :)
0
Comment
Question by:wildzero
  • 3
  • 3
6 Comments
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 125 total points
Comment Utility
I assume that you've 1 fixed row and no fixed col...

var
  Form1: TForm1;
  BlueCol: Integer;
implementation

{$R *.dfm}

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
If (ACOl=BlueCOl) and (ARow > 0) then
   StringGrid1.Canvas.Brush.Color := clNavy
else
   StringGrid1.Canvas.Brush.Color := clWIndow ;
   StringGrid1.Canvas.FillRect(Rect);
end;

procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
   BlueCOl := ACol;
   STringGrid1.Refresh;
end;

F68 ;-)
0
 
LVL 10

Author Comment

by:wildzero
Comment Utility
LoL, didn't think of doing it that way - well done :)
Doing it that way also solves another problem I thought I was going to have!!

Top job and speedy reply.
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
Comment Utility
Glad to have helped you :)

F68 ;-)
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

 
LVL 10

Author Comment

by:wildzero
Comment Utility
Ohh one thing (if u got a sec)
Can I make it so when I click say, a button I can select a row in a certain cell in the string grid?
Ie, click button and on the string grid it selects stringgrid.cells[0,2]
Thought there would be a way to call stringgrid.select[0,2] but alas there isnt. If its a quick 5 seconds then sweet. Otherwise I will create a new question :)

Cheers
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
Comment Utility
What about calling

Procedure TForm1.Button1CLick(Sender: TObject);
begin
   STringGrid1.Col := 0;
   StringGrid1.Row := 2;
end;
0
 
LVL 10

Author Comment

by:wildzero
Comment Utility
Perfect :)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 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

9 Experts available now in Live!

Get 1:1 Help Now