Solved

Color the colom of the selected cell

Posted on 2004-09-17
6
289 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
[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
6 Comments
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 125 total points
ID: 12089493
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
ID: 12089504
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
ID: 12089512
Glad to have helped you :)

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

 
LVL 10

Author Comment

by:wildzero
ID: 12089519
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
ID: 12089531
What about calling

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

Author Comment

by:wildzero
ID: 12089762
Perfect :)
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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

710 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