Paint problem with focusrect and selectedrow
Started by deonvn, Aug 02 2006 09:58 AM
10 replies to this topic
#1
Posted 02 August 2006 - 09:58 AM
Make a new grid and set "SelectFullRow := True".
Add some rows to the grid.
Click on a row to highlight the row, and then click on the header to sort by column.
The focusrect still shows on the row that was selected, but a different row is now highlighted.
Clicking on a new row will show the focusrect on the new row and highlight the new row, but the other focusrect also still shows, and the other highlighted row still shows.
Add some rows to the grid.
Click on a row to highlight the row, and then click on the header to sort by column.
The focusrect still shows on the row that was selected, but a different row is now highlighted.
Clicking on a new row will show the focusrect on the new row and highlight the new row, but the other focusrect also still shows, and the other highlighted row still shows.
#2
Posted 02 August 2006 - 02:41 PM
Hello,
I have see it now. This is on my to-do list, I will try to fix it as soon as possible.
Thank you,
regards
I have see it now. This is on my to-do list, I will try to fix it as soon as possible.
Thank you,
regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#3
Posted 09 August 2006 - 05:13 PM
Hi Boki
I see that this problem still remains in V3.9.
I have done some checking and the issue might be with SelectedRow property. The SelectedRow is not updated when a sort is done on a column.
For example:
If the top row of a grid is selected (Focused and Highlighted) and you query the SelectedRow property, the SelectedRow returns 0 (which is correct). If you now click on the header to invert the sort order of the column (so that the row that used to be at the top is now at the bottom) and then query the SelectedRow property again, it still return 0 (not correct - it should now be RowCount -1).
The correct row is HighLighted when painting takes place, but the FocusRect is still being drawn on the row that is currently the SelectedRow (Row 0).
Please have a look at this. I can not give the grid the my clients the way it is now.
Thanks
Deon
I see that this problem still remains in V3.9.
I have done some checking and the issue might be with SelectedRow property. The SelectedRow is not updated when a sort is done on a column.
For example:
If the top row of a grid is selected (Focused and Highlighted) and you query the SelectedRow property, the SelectedRow returns 0 (which is correct). If you now click on the header to invert the sort order of the column (so that the row that used to be at the top is now at the bottom) and then query the SelectedRow property again, it still return 0 (not correct - it should now be RowCount -1).
The correct row is HighLighted when painting takes place, but the FocusRect is still being drawn on the row that is currently the SelectedRow (Row 0).
Please have a look at this. I can not give the grid the my clients the way it is now.
Thanks
Deon
#4
Posted 09 August 2006 - 05:53 PM
Hello,
It is still unfixed, but I am working on it.
I will add notification when I fix it. Main problem is possible perfomance slowdown when sorting, but maybe it will not be.
regards
It is still unfixed, but I am working on it.
I will add notification when I fix it. Main problem is possible perfomance slowdown when sorting, but maybe it will not be.
regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#5
Posted 11 August 2006 - 01:03 PM
Hi Boki
Take a look at the code that I inserted at the start of the sorting procedure.
Now the Highlighted row will stay the same after the sort is finished (like it works for a single cell if SelecFullRow is False).
It also keeps the Selected rows if Multiselect is True.
It still doen't keep the "current record" (in other words the data in the selected row is different that it was before the sort), but at least it fixes the painting problems and won't impact performace.
Can you think of any reason why I shouldn't do this?
Let me know.
Deon
Take a look at the code that I inserted at the start of the sorting procedure.
CODE
procedure TCells.SortColumn(ACol: Integer; ASortType: TSortType;
ASortKind: TSortKind);
var
ALessCompFunc: TCompareFunc;
AGreaterCompFunc: TCompareFunc;
procedure Exchange(s, t: Integer);
var
P: Pointer;
i: Integer;
begin
//dvn - start new
if TRow(FRowsList[s]).Selected <> TRow(FRowsList[t]).Selected then
begin
TRow(FRowsList[s]).Selected := not TRow(FRowsList[s]).Selected;
TRow(FRowsList[t]).Selected := not TRow(FRowsList[t]).Selected;
end;
//dvn - end new
P := FRowsList[s];
FRowsList[s] := FRowsList[t];
FRowsList[t] := P;
for i := 0 to FColCount - 1 do
begin
P := FCellsList[i].Items[s];
FCellsList[i].Items[s] := FCellsList[i].Items[t];
FCellsList[i].Items[t] := P;
end;
end;
ASortKind: TSortKind);
var
ALessCompFunc: TCompareFunc;
AGreaterCompFunc: TCompareFunc;
procedure Exchange(s, t: Integer);
var
P: Pointer;
i: Integer;
begin
//dvn - start new
if TRow(FRowsList[s]).Selected <> TRow(FRowsList[t]).Selected then
begin
TRow(FRowsList[s]).Selected := not TRow(FRowsList[s]).Selected;
TRow(FRowsList[t]).Selected := not TRow(FRowsList[t]).Selected;
end;
//dvn - end new
P := FRowsList[s];
FRowsList[s] := FRowsList[t];
FRowsList[t] := P;
for i := 0 to FColCount - 1 do
begin
P := FCellsList[i].Items[s];
FCellsList[i].Items[s] := FCellsList[i].Items[t];
FCellsList[i].Items[t] := P;
end;
end;
Now the Highlighted row will stay the same after the sort is finished (like it works for a single cell if SelecFullRow is False).
It also keeps the Selected rows if Multiselect is True.
It still doen't keep the "current record" (in other words the data in the selected row is different that it was before the sort), but at least it fixes the painting problems and won't impact performace.
Can you think of any reason why I shouldn't do this?
Let me know.
Deon
#6
Posted 17 September 2006 - 04:58 PM
Hello,
I have fix it. If you agree, I will like to send you a update on your email to you test it.
regards
I have fix it. If you agree, I will like to send you a update on your email to you test it.
regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#7
Posted 17 September 2006 - 06:45 PM
Hi Boki
That would be great.
I have sent you my e-mail address. I will let you know as soon as I have tested it.
Thanks
Deon
That would be great.
I have sent you my e-mail address. I will let you know as soon as I have tested it.
Thanks
Deon
#8
Posted 18 September 2006 - 10:17 AM
Hi Boki
I have tested the source you sent me, and everything seems to be working fine now. The selected row is still selected after a sort, and the focusrect is painted on the correct row.
I also tested it with multiselect, and rowmoving and this also works fine - all selected rows are still selected after a sort on any column, and after moving rows.
It seems perfect now - thanks
Just a quick question:
After the sort operation, the selected row is sometimes not visible because its new position has been moved off the screen. This is easily fixed by using ScrollToRow(SelectedRow) after the sorting operation has been completed. I am just not sure which event to use. The only one I can find is the OnSort event, but I am not sure when this event fires.
Does OnSort fire while sorting is still going on, or only after the sorting has finished (OnAfterSort)?
Thanks again
Deon
I have tested the source you sent me, and everything seems to be working fine now. The selected row is still selected after a sort, and the focusrect is painted on the correct row.
I also tested it with multiselect, and rowmoving and this also works fine - all selected rows are still selected after a sort on any column, and after moving rows.
It seems perfect now - thanks
Just a quick question:
After the sort operation, the selected row is sometimes not visible because its new position has been moved off the screen. This is easily fixed by using ScrollToRow(SelectedRow) after the sorting operation has been completed. I am just not sure which event to use. The only one I can find is the OnSort event, but I am not sure when this event fires.
Does OnSort fire while sorting is still going on, or only after the sorting has finished (OnAfterSort)?
Thanks again
Deon
#9
Posted 18 September 2006 - 03:20 PM
Hello Deon,
Try to find method SortColumn in TNextGrid (NxGrid.pas). There you may add it. I will do same too.
regards
Try to find method SortColumn in TNextGrid (NxGrid.pas). There you may add it. I will do same too.
regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#10
Posted 18 September 2006 - 05:25 PM
Hi, Boki
Can you post the source code to fix the problem here since I'm still using the old version in some of my projects?
Thanks
William
Can you post the source code to fix the problem here since I'm still using the old version in some of my projects?
Thanks
William
#11
Posted 18 September 2006 - 07:25 PM
Hello William,
Please contact me via email and I will send it to you.
regards
Please contact me via email and I will send it to you.
regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











