Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

TDrawGrid..can it do this????????????????

Posted on 2002-04-12
7
Medium Priority
?
238 Views
Last Modified: 2010-04-04
hihi..
  I want to use TDrawGrid to finish the following function,can it do this??????????
Wanted Function:
  When I click on a grid the color of the current grid can change. or just like :
   DrawGrid1.Rect(1,2).Color:=clBlue;
can I?????????????????????????????????????
                               wind
0
Comment
Question by:windyui
[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
  • 2
  • 2
7 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6936251
yes, could be done,
but not in this way

DrawGrid1.Rect(1,2).Color:=clBlue;

look at the ownerdraw-features

more points, more advice

meikl ;-)
0
 
LVL 9

Accepted Solution

by:
ITugay earned 117 total points
ID: 6936404
Hi windyui,

it looks like all of yours available points :-)

meikl :-)

may be something like this?

procedure TForm1.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
  with DrawGrid1 do
  begin
    if gdSelected in State then
      Canvas.Brush.Color := clLime;
    Canvas.FillRect(CellRect(ACol, ARow));
  end;
end;

----
Igor.


0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6936414
>it looks like all of yours available points :-)

guessing no,
member since 1999, question asked 10
must have thousends of points

for q lower 50 pts i gave only hints

hi igor ;-)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 9

Expert Comment

by:ITugay
ID: 6936425
oh nooooooooo, it was a trick! :-)
0
 

Author Comment

by:windyui
ID: 6936769
Hi, Igor
   Yor are almost Right. the Currect answer is
on the ONMOUSEDOWN Event:
begin
 MouseToCell(X,Y,Col,Row);
 with DrawGrid1 do
 begin
   Canvas.Brush.Color := clLime;
   Canvas.FillRect(CellRect(ACol, ARow));
 end;
end;

0
 
LVL 9

Expert Comment

by:ITugay
ID: 6938520
hi windyui,

not very sure about your solution. Let suppose you need to show any text or graphic in cell. Then you have to write OnDrawCell implementation and the same code for OnMouseDown event. So, OnMouseDown is only partial solution, however OnDrawCell is more logical and universal one.

and I think that you code wouldn't work even if you specify DefaultDrawing = False:

1. MouseToCell(X,Y,Col,Row); should be bellow "with DrawGrid1 do"
2. you can't pass Col and Row as parameters to MouseToCell
3. after Grid will be repainted, all cell's will be white again.

to solve this problem you have to store cell's colors somewhere, let say in matrix.

------
Igor

0
 

Author Comment

by:windyui
ID: 6940124
HI,Igor
   Yes you r right.WHen other windows upon (e.g. The Message window) the Cells ,the color LOST and become white again.
   I will try to store the color in a Matrix.Thx...


                                           windyui
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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

705 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