﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » Saving focused row on EnhancedList requery</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 05:39:32 GMT</lastBuildDate><ttl>20</ttl><item><title>Saving focused row on EnhancedList requery</title><link>http://forum.strataframe.net/FindPost2537.aspx</link><description>I'm doing a requery of an EnhancedList after making some updates to the BO that I have bound to it.&amp;nbsp; After the requery the focus always jumps to the top of the list.&amp;nbsp; Is there a way to keep it from doing this and have the focus make sense.&amp;nbsp; i.e. Focus on a newly added row, focus on the next if one is&amp;nbsp;deleted, and keep current focus on an edit?</description><pubDate>Tue, 29 Aug 2006 15:48:13 GMT</pubDate><dc:creator>Andria Jensen</dc:creator></item><item><title>RE: Saving focused row on EnhancedList requery</title><link>http://forum.strataframe.net/FindPost2543.aspx</link><description>Well, store off the PK of the row.&amp;nbsp; When you setup the PopulationDataSourceSettings, you can provide the field that will be stored in the Tag property of each row.&amp;nbsp; Get the PK value and then iterate through the rows when repopulated and set the item that has a matching PK.</description><pubDate>Tue, 29 Aug 2006 15:48:13 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Saving focused row on EnhancedList requery</title><link>http://forum.strataframe.net/FindPost2542.aspx</link><description>But wouldn't the index change if my list is sorted and something gets added into the middle of it?&amp;nbsp; 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.</description><pubDate>Tue, 29 Aug 2006 15:20:44 GMT</pubDate><dc:creator>Andria Jensen</dc:creator></item><item><title>RE: Saving focused row on EnhancedList requery</title><link>http://forum.strataframe.net/FindPost2541.aspx</link><description>Something that may help me...what is actually under the Requery?&amp;nbsp; It appears that it is just creating a data table from the populated BO and setting the DataSource property.&amp;nbsp; Is there anything else going on?&amp;nbsp; I can't exactly ask DevExpress why my focus changes on Requery because they don't know what I'm talking about there.</description><pubDate>Tue, 29 Aug 2006 15:19:00 GMT</pubDate><dc:creator>Andria Jensen</dc:creator></item><item><title>RE: Saving focused row on EnhancedList requery</title><link>http://forum.strataframe.net/FindPost2540.aspx</link><description>It is because you are saving off a row instance.&amp;nbsp; When the grid is re-populated it creates new rows and makes the row reference you have obselete.&amp;nbsp; You need to save off the index, because that should not change.</description><pubDate>Tue, 29 Aug 2006 15:10:01 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Saving focused row on EnhancedList requery</title><link>http://forum.strataframe.net/FindPost2539.aspx</link><description>&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;I am doing this:&lt;/P&gt;&lt;P&gt;Dim&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; SaveFocusedRow &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Object&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; RowHandle &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Integer&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;SaveFocusedRow = gvHdr.GetRow(gvHdr.FocusedRowHandle)&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;BR&gt;grdHdr.Requery()&amp;nbsp; &lt;BR&gt;&lt;BR&gt;RowHandle = FindRowHandleByRowObject(gvHdr, SaveFocusedRow) &lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/FONT&gt;&lt;FONT size=2&gt; RowHandle &amp;lt;&amp;gt; DevExpress.XtraGrid.GridControl.InvalidRowHandle &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Then&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp; gvHdr.FocusedRowHandle = RowHandle&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;But it's not able to find the row in the list, it keeps returning back InvalidRowHandle.&amp;nbsp; I originally did go to DevExpress help and this was what I was told to do.&amp;nbsp; 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.&amp;nbsp; I'll keep looking...this seems like it should be easy but it's proving to be rather difficult.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;The FindRowHandleByRowObject Function is defined as below:&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;Private&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Function&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; FindRowHandleByRowObject(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; view &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; DevExpress.XtraGrid.Views.Grid.GridView, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; row &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Object&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;) &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Integer&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp; If&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Not&lt;/FONT&gt;&lt;FONT size=2&gt; row &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Is&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Nothing&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Then&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; For&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp;i as Integer = 0 &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;To&lt;/FONT&gt;&lt;FONT size=2&gt; view.DataRowCount - 1&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If&lt;/FONT&gt;&lt;FONT size=2&gt; row.Equals(view.GetRow(i)) &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Then&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp;i&amp;nbsp;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp; End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp; Return&lt;/FONT&gt;&lt;FONT size=2&gt; DevExpress.XtraGrid.GridControl.InvalidRowHandle&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Function&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;</description><pubDate>Tue, 29 Aug 2006 15:06:51 GMT</pubDate><dc:creator>Andria Jensen</dc:creator></item><item><title>RE: Saving focused row on EnhancedList requery</title><link>http://forum.strataframe.net/FindPost2538.aspx</link><description>I am sure that there is but you will be better served looking at the DevExpress help.&amp;nbsp; Off the top of my head I do not know and I would have to look into this myself.&amp;nbsp; But you should be able to set the focused row and then call a method like EnsureVisible to make sure that it is active.&amp;nbsp; You can place all of the code to do this in the AfterRequery method.&amp;nbsp; Also, the control to look at in DevExpresss would be a GridView.&amp;nbsp; This is the type of view used inside of the grid.&amp;nbsp; You can access it thought the MainView property on the grid and just CType it as a GridView.</description><pubDate>Tue, 29 Aug 2006 14:59:50 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>