Hi,
one problem solved, the next one is knocking on my door...
If I assign an index to NextGrid.SelectedRow, it is still -1 afterwards if I read the property. I did called NoSelection before the assignment.
Another problem is that if I assign NextGrid.Selected[i] := True, the NextGrid.SelectedRow is also still -1 afterwards.
What is the exact difference between Selected[i] and SelectedRow and why I cannot assign values properly?
The origin of the problem is:
I made the experience (in previous grid versions) that the selection or focus of the rows is not painted properly in some cases (if grid looses focus and gets it back and you click on some other row the previous selection is still there - as far as I can remember). That is why I used a trick. Into the GridCellSelect I put two lines:
Grid.NoSelecton;
Grid.Selected[i] := ARow;
...and painting problems where gone.
With the latest NextGrid it doesn't work properly (I recognized it with the latest, maybe it was already there in earlier versions).
However, with these two lines in the code, you can't click into the grid and press e.g. key down. Because you check for the VK_DOWN key and then you call
GetCellRect(SelectedColumn, SelectedRow).Bottom
in NxCustomGridControl (procedure MoveSelectionDown)
whereby the SelectedRow of -1 leads to an exception (out of bounds blabla).
Update: well, I just tried to remove "the trick" but without these two lines of code, the painting bug still appears. It is stupid.
BR
DW
Assigning the selected row
Started by downwards1, Apr 01 2007 11:08 PM
4 replies to this topic
#1
Posted 01 April 2007 - 11:08 PM
#2
Posted 02 April 2007 - 05:37 AM
Hello downwards,
Selected[] do not automatically set SelectedRow. Selected[] is a array of all rows which tell if row is selected or not (true/false).
Main thing is that one row can be equal to SelectedRow, but not selected (Selected[SelectedRow] = False)
If you can send me a small sample app this will help. I have already apply NoSelection fix.
regards
Selected[] do not automatically set SelectedRow. Selected[] is a array of all rows which tell if row is selected or not (true/false).
Main thing is that one row can be equal to SelectedRow, but not selected (Selected[SelectedRow] = False)
If you can send me a small sample app this will help. I have already apply NoSelection fix.
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 02 April 2007 - 01:03 PM
It seems that my painting "bug" is selfmade. I have two grids A& B: In general, each row of grid A is linked to a row in grid B and reverse. "Linked" means if you click on a row in grid A the partner entry (row) in grid B is selected too. It seems that I use SelectedRow and/or Selected[i] in a wrong way. Currently if I click onto a row X in grid A -> the partner row Y in grid B is selected too -> now if I click in grid B onto another row Z, the selection of the row Y doesn't go away. It stays until I explicitely click onto row Y followed by some other row.
Ok, because I'm still confused with SelectedRow and Selected[i], what is the exact way I have to go to select one row of a grid by code, the previous selections in this grid shall be forgotten and the grid shall show the selection properly?
Thanx a lot!
BR
DW
Ok, because I'm still confused with SelectedRow and Selected[i], what is the exact way I have to go to select one row of a grid by code, the previous selections in this grid shall be forgotten and the grid shall show the selection properly?
Thanx a lot!
BR
DW
#4
Posted 03 April 2007 - 05:29 AM
Hello Downwards,
If you want to select one row in grid, use SelectedRow. This property will not be changed after setting Selected[x] := true/false , but when you set SelectedRow, all selected rows from Selected[] will be set to False.
If you try to select few rows with holding down CTRL, you will see that you may set selected row to be un-selected (but focused)
I hope that this help a little bit
regards
If you want to select one row in grid, use SelectedRow. This property will not be changed after setting Selected[x] := true/false , but when you set SelectedRow, all selected rows from Selected[] will be set to False.
If you try to select few rows with holding down CTRL, you will see that you may set selected row to be un-selected (but focused)
I hope that this help a little bit
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 03 April 2007 - 11:08 AM
Now it works perfectly! I had some Selected[i] in my code which disturbed the whole selected mechanism.
Thanx for your support!
BR
DW
Thanx for your support!
BR
DW
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











