Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2002-04-12
7
Medium Priority
?
241 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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

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 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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

926 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