The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Datagrid - set focus on row
Posted: 14 Dec 07 9:45 AM
|
Hi all,
I have a datagrid that is being populated by a large amount of records. When the user deletes a selected amount of rows, I want to set focus on the row previous to his selection. How can I do this?
Thanks! |
|
|
|
Re: Datagrid - set focus on row
Posted: 14 Dec 07 10:36 AM
|
First of all, this works well in newer versions of SLX, but the earlier versions (maybe earlier than 6.2.4) of the datagrid you didn't have the ability to select a row. What version is this for?
To do this, you'll need to determine the ID value of the row you'd like to select after the delete occurs. The best way I can think of off top of my head is to take the grid's recordset, loop though it until you find the selected row, and then use the value from the row right before it. Once you have the ID value you can proceed with the delete.
After the delete, you'll select the row by adding the ID value from the row you determined was the row you wanted to select to the grid's Selection collection.
DataGrid1.Selection.Add id
Make sense? For the Selection collection to work at all (to read the selected rows or set them) you'll need to add the ID field for the table to the grid (and then hide it).
-Ryan |
|
|
|
Re: Datagrid - set focus on row
Posted: 14 Dec 07 10:45 AM
|
Hi Ryan,
I had noticed that in newer releases this would be easier. I'm unfortunately stuck with 6.x.
I actually already have IDs (hidden values) in the grid, so I can loop through and find what ID it is previous to the selection I delete. What function do I use to setfocus? |
|
|
|
Re: Datagrid - set focus on row
Posted: 14 Dec 07 12:52 PM
|
Adding the ID values to the grid's Selection collection is what "selects" them. Depending on what version of 6.x you're on, you might or might not even have a Selection collection for your grid (if it doesn't show up in the intellisense then you're SOL - there was no way to programatically select rows in early versions) |
|
|
|
Re: Datagrid - set focus on row
Posted: 09 Jun 08 9:50 AM
|
Hello, I'm running SLX 7.2.2 and when programatically selecting a the row using the method described, if the newly selected record is not showing (outside scroll range) the grid is not auto-scrolling to that record. Any thoughts?
...Rob |
|
|
|
Re: Datagrid - set focus on row
Posted: 09 Jun 08 9:50 AM
|
Hello, I'm running SLX 7.2.2 and when programatically selecting a the row using the method described, if the newly selected record is not showing (outside scroll range) the grid is not auto-scrolling to that record. Any thoughts?
...Rob |
|
|
| |
| |
|