Board index » cppbuilder » StringGrid with grid out of indes range...

StringGrid with grid out of indes range...


2004-12-01 04:22:43 PM
cppbuilder114
Hi all,
known error to all us here. Nevertheless I wanted ask for a
possible workaround. I have StringGrid with OnDrawCell event
where I'm painting the grid by myself. This works perfectly.
But normally at the beginning the first row (I make row
selection) is selected. Also when I'm leaving the grid the last
selection that I've made is shown.
It is not a option to me to draw the selected row in the normal
backgroung color, because when I'm inside the grid, the selected
rows should be highlighted anyway.
So, I have tried it with:
Rect.Left = -1;
Rect.Top = -1;
Rect.Right = -1;
Rect.Bottom = -1;
StringGrid1->Selection = Rect;
But then I'm getting the error mentioned in the topic when I
move my mouse over the grid. So have I a chance to solve
this issues in a good way??
Thanks for any hints in advance,
Mauro
 
 

Re:StringGrid with grid out of indes range...

"Mauro" < XXXX@XXXXX.COM >wrote:
Quote

[...] So have I a chance to solve this issues in a good way??
In the OnDrawCell event, where you test for the cell being
selected, add and extra test to see if the grid is Focused().
If it is, use the clHighlight else use the normal color.
Then add an OnExit event where all you do is Invalidate() the
grid.
~ JD
 

Re:StringGrid with grid out of indes range...

Hi DJ ;-)
sounds good but does not help me. With "Selection" I've
mentioned when I move my mouse over a row then it is
highlighted and as you know the grid must be not focused
at this time. So I need a possibility to determine if the
mouse coordinates are still inside the grid or outside the
grid, hmm, this should be not possible at all...
Thanks Marius
"JD" < XXXX@XXXXX.COM >wrote:
Quote

"Mauro" < XXXX@XXXXX.COM >wrote:
>
>[...] So have I a chance to solve this issues in a good way??

In the OnDrawCell event, where you test for the cell being
selected, add and extra test to see if the grid is Focused().
If it is, use the clHighlight else use the normal color.

Then add an OnExit event where all you do is Invalidate() the
grid.

~ JD

 

{smallsort}

Re:StringGrid with grid out of indes range...

@Hans: I have done it once in the constructor of my form!
@JD: I have solved it with the TAG value->
OnMouseEnter: TAG = 1;
OnMouseLeave: TAG = 0;
In OnDrawCell I'm checking this and paint the 'selected'
row with highlighted color if TAG = 1, otherwise with
the background color. So at all I have used your suggestion
in a little bit other way ;-)
Thanks to all,
Mauro
 

Re:StringGrid with grid out of indes range...

Mauro wrote:
Quote
known error to all us here.
Please do not refer to the Subject. Place all info in the body.
Quote
So, I have tried it with:

Rect.Left = -1;
Rect.Top = -1;
Rect.Right = -1;
Rect.Bottom = -1;
StringGrid1->Selection = Rect;
You did not tell when you execute that code.
For me this works:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TGridRect myRect;
myRect.Left = -1;
myRect.Top = -1;
myRect.Right = -1;
myRect.Bottom = -1;
StringGrid1->Selection = myRect;
}
Quote
But then I'm getting the error mentioned in the topic when I
move my mouse over the grid.
Are you executing that in MouseMove() or so ? You only need
to execute that code once. Now and then maybe. I forgot.
Hans.