﻿<?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?)  » Grandchild Listview</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 04:00:17 GMT</lastBuildDate><ttl>20</ttl><item><title>Grandchild Listview</title><link>http://forum.strataframe.net/FindPost23077.aspx</link><description>I have a child form opened from a listview using the automation features - all works fine. On that child form I have another listview which again opens a form - this form opens and closes OK but I cannot add a new record to the list - it's missing the primary key. If I manually add records to the table they display OK and I can edit them. I think the parent-child relationships are set OK on the BO's.&lt;/P&gt;&lt;P&gt;Does the basic listview automation work when called from a child form or do I need to handle this differently?&lt;/P&gt;&lt;P&gt;Thanks</description><pubDate>Wed, 13 May 2009 09:56:58 GMT</pubDate><dc:creator>Mike Tomlin</dc:creator></item><item><title>RE: Grandchild Listview</title><link>http://forum.strataframe.net/FindPost23092.aspx</link><description>Thanks for the tips but it didn't sort the delete action not refreshing the listview. For the moment I've opted to handle the delete action in code and that's working OK now and I'll&amp;nbsp;try later&amp;nbsp;to see if I can get it to work with the fully automated options.</description><pubDate>Wed, 13 May 2009 09:56:58 GMT</pubDate><dc:creator>Mike Tomlin</dc:creator></item><item><title>RE: Grandchild Listview</title><link>http://forum.strataframe.net/FindPost23088.aspx</link><description>Edhy is correct in that the StrataFlix shows a number of examples on this and does fully support the most recent version of SF.&amp;nbsp; Also, if you are allowing the delete to be handled automatically through the ListView, it will remove the record.&amp;nbsp; The issue that you may be fighting if the deletion is not being reflected further upstream is due to the BO translations.&lt;/P&gt;&lt;P&gt;All translations take place at the time of the Load event.&amp;nbsp; All code references are updated, however, there are times that you need to manually update the object instance references and this may be one of them.&amp;nbsp; We do not reflect through all of the objects on the form as this would be very slow using reflection.&amp;nbsp; So if you override the OnLoad method of the form&amp;nbsp;and manually update the reference on the list, it may resolve your issue.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;VB.NET&lt;/STRONG&gt;&lt;BR&gt;[codesnippet]Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyBase.OnLoad(e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lstList.BusinessObject = MyBo&lt;BR&gt;End Sub[/codesnippet]&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;C#&lt;BR&gt;&lt;/STRONG&gt;[codesnippet]protected override void OnLoad(EventArgs e)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; base.OnLoad(e);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lstList.BusinessObject = MyBo;&lt;BR&gt;}[/codesnippet]</description><pubDate>Wed, 13 May 2009 06:47:21 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Grandchild Listview</title><link>http://forum.strataframe.net/FindPost23083.aspx</link><description>The Delete should requrery your listview automatically.  Also in the ChildFormResults the parameter e.Requery = True will requery the listview based on the parameters you have in the ListPopulating event.  Again the StrataFlix uses the latest release of the SF and shows how to handle this with much clear code, even thought what you are doing is OK by passing the parameter to the Requery().</description><pubDate>Tue, 12 May 2009 09:59:24 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Grandchild Listview</title><link>http://forum.strataframe.net/FindPost23082.aspx</link><description>Thinking about it this is only called when the child form launched from the listview is involved. In a delete from the listview&amp;nbsp;the child form is not launched.</description><pubDate>Tue, 12 May 2009 09:47:49 GMT</pubDate><dc:creator>Mike Tomlin</dc:creator></item><item><title>RE: Grandchild Listview</title><link>http://forum.strataframe.net/FindPost23081.aspx</link><description>I already had in place this...&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Private&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; ListView1_ChildFormResults(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; sender &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; System.Object, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; e &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; MicroFour.StrataFrame.UI.Windows.Forms.ListViewChildFormResultsEventArgs) &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Handles&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; ListView1.ChildFormResults&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; e.Results = Windows.Forms.DialogResult.OK &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Then&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;'-- Save the BO&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.Trans_failure_item_BO1.Save()&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Else&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.Trans_failure_item_BO1.RestoreCurrentDataTableSnapshot(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;False&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;'-- Force the listview to requery&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.ListView1.Requery(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;CInt&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.Trans_route_Master_BO1.CurrentRow.Item(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"route_pk_id"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;)))&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;/FONT&gt;[/codesnippet]&lt;P&gt;the listview is filled by the parent primary key and this should force it to requery - it must be working after an add or edit as the display is fine - just the delete goes blank.</description><pubDate>Tue, 12 May 2009 09:43:31 GMT</pubDate><dc:creator>Mike Tomlin</dc:creator></item><item><title>RE: Grandchild Listview</title><link>http://forum.strataframe.net/FindPost23080.aspx</link><description>[quote][b]Mike Tomlin (05/12/2009)[/b][hr]...do I need to help the automation in this case?[/quote]&lt;br&gt;
&lt;br&gt;
Yes, the ListView has an event named "ChildFormResults" which you use to make the automation feature to requery the listview.  Here is a sample code from one of my listview:&lt;br&gt;
&lt;br&gt;
[codesnippet][code]&lt;br&gt;
Private Sub lstTransactionItems_ChildFormResults(ByVal sender As System.Object, ByVal e As MicroFour.StrataFrame.UI.Windows.Forms.ListViewChildFormResultsEventArgs) Handles lstTransactionItems.ChildFormResults&lt;br&gt;
        If e.Results = Windows.Forms.DialogResult.Cancel Then&lt;br&gt;
            Me.BizTransactionItems1.RestoreCurrentDataTableSnapshot(False)&lt;br&gt;
        Else&lt;br&gt;
            e.Requery = True&lt;br&gt;
        End If&lt;br&gt;
    End Sub&lt;br&gt;
[/code][/codesnippet]&lt;br&gt;
&lt;br&gt;
Also keep in mind that when you delete a record, it may be marked as Deleted only and in that case it will require you to Save() the BO to actually delete the record, there is a property in the listview which controls this feature.&lt;br&gt;
&lt;br&gt;
The StrataFlix sample application has several listview used which demonstrate this approach.</description><pubDate>Tue, 12 May 2009 09:32:53 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Grandchild Listview</title><link>http://forum.strataframe.net/FindPost23079.aspx</link><description>Thanks Edhy that's sorted the adding I must have missed that post whilst searching the forum. &lt;/P&gt;&lt;P&gt;The only issue I have left is that if I delete, again using the automation, on deletion the list box is clearing and showing no records. The deletion has happened OK but probably something's amiss with the requerying - do I need to help the automation in this case?</description><pubDate>Tue, 12 May 2009 09:17:20 GMT</pubDate><dc:creator>Mike Tomlin</dc:creator></item><item><title>RE: Grandchild Listview</title><link>http://forum.strataframe.net/FindPost23078.aspx</link><description>Hi Mike,&lt;br&gt;
&lt;br&gt;
Take a look at this post: [url]http://forum.strataframe.net/FindPost22673.aspx[/url] guess it is related to your situation and the way the BOs gets translated to the childform.</description><pubDate>Tue, 12 May 2009 08:45:30 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item></channel></rss>