StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Saving focused row on EnhancedList requeryExpand / Collapse
Author
Message
Posted 08/29/2006 2:56:08 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame 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?
Post #2537
Posted 08/29/2006 2:59:50 PM


StrataFrame Developer

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.
Post #2538
Posted 08/29/2006 3:06:51 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame 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 Integer

SaveFocusedRow = gvHdr.GetRow(gvHdr.FocusedRowHandle)

grdHdr.Requery() 

RowHandle = FindRowHandleByRowObject(gvHdr, SaveFocusedRow)

If RowHandle <> DevExpress.XtraGrid.GridControl.InvalidRowHandle Then   
  gvHdr.FocusedRowHandle = RowHandle
End If

But 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.InvalidRowHandle

End Function

Post #2539
Posted 08/29/2006 3:10:01 PM


StrataFrame Developer

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.
Post #2540
Posted 08/29/2006 3:19:00 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame 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.
Post #2541
Posted 08/29/2006 3:20:44 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame 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.
Post #2542
Posted 08/29/2006 3:48:13 PM


StrataFrame Developer

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.
Post #2543
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 3:16am

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.125. 11 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.