| | | 
StrataFrame User
       
Group: StrataFrame Users Last Login: 11/25/2008 10:33:22 AM Posts: 318, Visits: 460 |
| | I'm doing a requery of an EnhancedList after making some updates to the BO that I have bound to it. After the requery the focus always jumps to the top of the list. Is there a way to keep it from doing this and have the focus make sense. i.e. Focus on a newly added row, focus on the next if one is deleted, and keep current focus on an edit? |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Yesterday @ 7:08:30 PM Posts: 4,811, Visits: 4,781 |
| | I am sure that there is but you will be better served looking at the DevExpress help. Off the top of my head I do not know and I would have to look into this myself. But you should be able to set the focused row and then call a method like EnsureVisible to make sure that it is active. You can place all of the code to do this in the AfterRequery method. Also, the control to look at in DevExpresss would be a GridView. This is the type of view used inside of the grid. You can access it thought the MainView property on the grid and just CType it as a GridView. |
| | | | 
StrataFrame User
       
Group: StrataFrame Users Last Login: 11/25/2008 10:33:22 AM Posts: 318, Visits: 460 |
| I am doing this: Dim SaveFocusedRow As Object Dim RowHandle As IntegerSaveFocusedRow = gvHdr.GetRow(gvHdr.FocusedRowHandle)
grdHdr.Requery()
RowHandle = FindRowHandleByRowObject(gvHdr, SaveFocusedRow) If RowHandle <> DevExpress.XtraGrid.GridControl.InvalidRowHandle Then gvHdr.FocusedRowHandle = RowHandle End IfBut it's not able to find the row in the list, it keeps returning back InvalidRowHandle. I originally did go to DevExpress help and this was what I was told to do. However, it's not working so I wasn't sure if there was something in the EnhancedList conflicting with it or something else that I could use instead. I'll keep looking...this seems like it should be easy but it's proving to be rather difficult. The FindRowHandleByRowObject Function is defined as below: Private Function FindRowHandleByRowObject(ByVal view As DevExpress.XtraGrid.Views.Grid.GridView, ByVal row As Object) As Integer If Not row Is Nothing Then For i as Integer = 0 To view.DataRowCount - 1 If row.Equals(view.GetRow(i)) Then Return i Next End If Return DevExpress.XtraGrid.GridControl.InvalidRowHandleEnd Function |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Yesterday @ 7:08:30 PM Posts: 4,811, Visits: 4,781 |
| | It is because you are saving off a row instance. When the grid is re-populated it creates new rows and makes the row reference you have obselete. You need to save off the index, because that should not change. |
| | | | 
StrataFrame User
       
Group: StrataFrame Users Last Login: 11/25/2008 10:33:22 AM Posts: 318, Visits: 460 |
| | Something that may help me...what is actually under the Requery? It appears that it is just creating a data table from the populated BO and setting the DataSource property. Is there anything else going on? I can't exactly ask DevExpress why my focus changes on Requery because they don't know what I'm talking about there. |
| | | | 
StrataFrame User
       
Group: StrataFrame Users Last Login: 11/25/2008 10:33:22 AM Posts: 318, Visits: 460 |
| | But wouldn't the index change if my list is sorted and something gets added into the middle of it? This is fine for an edit where i want the focus to stay on the same one and nothing is added or deleted, but that won't work for new rows or for deletes. |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Yesterday @ 7:08:30 PM Posts: 4,811, Visits: 4,781 |
| | Well, store off the PK of the row. When you setup the PopulationDataSourceSettings, you can provide the field that will be stored in the Tag property of each row. Get the PK value and then iterate through the rows when repopulated and set the item that has a matching PK. |
| |
|
|