<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Switching layouts &amp; Windows form doesn't work in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/switching-layouts-windows-form-doesn-t-work/m-p/2118330#M76381</link>
    <description>Thanks for the suggestion. I added the parenthesis' because of the way the object browser lists the property.&lt;BR /&gt;
&lt;BR /&gt;
Removed it and it still doesn't work. The code with the parenthesis actually works just not in the button clicked event of the form....&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
    <pubDate>Fri, 16 Nov 2007 22:10:44 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2007-11-16T22:10:44Z</dc:date>
    <item>
      <title>Switching layouts &amp; Windows form doesn't work</title>
      <link>https://forums.autodesk.com/t5/net-forum/switching-layouts-windows-form-doesn-t-work/m-p/2118328#M76379</link>
      <description>I am working with a plotting macro and my WindowsForm needs to activate a layout...Here is the problem. It doesn't work.&lt;BR /&gt;
&lt;BR /&gt;
The method I am using to switch the layout is:&lt;BR /&gt;
        LayoutManager.Current.CurrentLayout() = "Layout1"&lt;BR /&gt;
&lt;BR /&gt;
I know this works since if I have it like below without loading form it works fine:&lt;BR /&gt;
&lt;BR /&gt;
     Public Sub TestLayout()&lt;BR /&gt;
        LayoutManager.Current.CurrentLayout() = "Layout1"&lt;BR /&gt;
    End Sub&lt;BR /&gt;
&lt;BR /&gt;
The one line of code will also work if its place inside the Form_Load event of the form i'm using...But once I place the code in any Button_Clicked event it doesn't work anymore. The drawing stays in Model space and a prompt says it regening layout...The code you can try is below:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
 Public Sub TestLayout()&lt;BR /&gt;
        Dim frm As New Form1&lt;BR /&gt;
        frm.Show()&lt;BR /&gt;
    End Sub&lt;BR /&gt;
&lt;BR /&gt;
Imports Autodesk.AutoCAD.DatabaseServices&lt;BR /&gt;
Public Class Form1&lt;BR /&gt;
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click&lt;BR /&gt;
        LayoutManager.Current.CurrentLayout() = "Layout1"&lt;BR /&gt;
    End Sub&lt;BR /&gt;
End Class</description>
      <pubDate>Thu, 15 Nov 2007 23:11:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/switching-layouts-windows-form-doesn-t-work/m-p/2118328#M76379</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-11-15T23:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: Switching layouts &amp; Windows form doesn't work</title>
      <link>https://forums.autodesk.com/t5/net-forum/switching-layouts-windows-form-doesn-t-work/m-p/2118329#M76380</link>
      <description>CurrentLayout()?&lt;BR /&gt;
&lt;BR /&gt;
LayoutManager.CurrentLayout is  a property of String type, not a method. &lt;BR /&gt;
Remove the bracket from your code.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;DAHOVEY&gt; wrote in message news:5779159@discussion.autodesk.com...&lt;BR /&gt;
I am working with a plotting macro and my WindowsForm needs to activate a &lt;BR /&gt;
layout...Here is the problem. It doesn't work.&lt;BR /&gt;
&lt;BR /&gt;
The method I am using to switch the layout is:&lt;BR /&gt;
        LayoutManager.Current.CurrentLayout() = "Layout1"&lt;BR /&gt;
&lt;BR /&gt;
I know this works since if I have it like below without loading form it &lt;BR /&gt;
works fine:&lt;BR /&gt;
&lt;BR /&gt;
     Public Sub TestLayout()&lt;BR /&gt;
        LayoutManager.Current.CurrentLayout() = "Layout1"&lt;BR /&gt;
    End Sub&lt;BR /&gt;
&lt;BR /&gt;
The one line of code will also work if its place inside the Form_Load event &lt;BR /&gt;
of the form i'm using...But once I place the code in any Button_Clicked &lt;BR /&gt;
event it doesn't work anymore. The drawing stays in Model space and a prompt &lt;BR /&gt;
says it regening layout...The code you can try is below:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
 Public Sub TestLayout()&lt;BR /&gt;
        Dim frm As New Form1&lt;BR /&gt;
        frm.Show()&lt;BR /&gt;
    End Sub&lt;BR /&gt;
&lt;BR /&gt;
Imports Autodesk.AutoCAD.DatabaseServices&lt;BR /&gt;
Public Class Form1&lt;BR /&gt;
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As &lt;BR /&gt;
System.EventArgs) Handles Button1.Click&lt;BR /&gt;
        LayoutManager.Current.CurrentLayout() = "Layout1"&lt;BR /&gt;
    End Sub&lt;BR /&gt;
End Class&lt;/DAHOVEY&gt;</description>
      <pubDate>Fri, 16 Nov 2007 14:26:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/switching-layouts-windows-form-doesn-t-work/m-p/2118329#M76380</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-11-16T14:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: Switching layouts &amp; Windows form doesn't work</title>
      <link>https://forums.autodesk.com/t5/net-forum/switching-layouts-windows-form-doesn-t-work/m-p/2118330#M76381</link>
      <description>Thanks for the suggestion. I added the parenthesis' because of the way the object browser lists the property.&lt;BR /&gt;
&lt;BR /&gt;
Removed it and it still doesn't work. The code with the parenthesis actually works just not in the button clicked event of the form....&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
      <pubDate>Fri, 16 Nov 2007 22:10:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/switching-layouts-windows-form-doesn-t-work/m-p/2118330#M76381</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-11-16T22:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Switching layouts &amp; Windows form doesn't work</title>
      <link>https://forums.autodesk.com/t5/net-forum/switching-layouts-windows-form-doesn-t-work/m-p/2118331#M76382</link>
      <description>Try this instead, it was working for me in A2008 &lt;BR /&gt;
&lt;BR /&gt;
Public Class Form1&lt;BR /&gt;
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click&lt;BR /&gt;
        Dim ed As Editor = AcadApp.DocumentManager.MdiActiveDocument.Editor&lt;BR /&gt;
        Dim Db As Database = HostApplicationServices.WorkingDatabase&lt;BR /&gt;
        Using locked As Autodesk.AutoCAD.ApplicationServices.DocumentLock = AcadApp.DocumentManager.MdiActiveDocument.LockDocument()&lt;BR /&gt;
            Using trans As Transaction = Db.TransactionManager.StartTransaction()&lt;BR /&gt;
                LayoutManager.Current.CurrentLayout = "Layout1"&lt;BR /&gt;
                ed.Regen()&lt;BR /&gt;
                trans.Commit()&lt;BR /&gt;
            End Using&lt;BR /&gt;
        End Using&lt;BR /&gt;
    End Sub&lt;BR /&gt;
End Class&lt;BR /&gt;
&lt;BR /&gt;
~'J'~</description>
      <pubDate>Sat, 17 Nov 2007 17:08:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/switching-layouts-windows-form-doesn-t-work/m-p/2118331#M76382</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-11-17T17:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: Switching layouts &amp; Windows form doesn't work</title>
      <link>https://forums.autodesk.com/t5/net-forum/switching-layouts-windows-form-doesn-t-work/m-p/2118332#M76383</link>
      <description>Awesome! That worked. Added everything piece by piece. It ended up that locking the document is needed.&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Mon, 19 Nov 2007 19:14:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/switching-layouts-windows-form-doesn-t-work/m-p/2118332#M76383</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-11-19T19:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: Switching layouts &amp; Windows form doesn't work</title>
      <link>https://forums.autodesk.com/t5/net-forum/switching-layouts-windows-form-doesn-t-work/m-p/2118333#M76384</link>
      <description>Always happy to help&lt;BR /&gt;
Cheers &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
~'J'~</description>
      <pubDate>Tue, 20 Nov 2007 09:21:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/switching-layouts-windows-form-doesn-t-work/m-p/2118333#M76384</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-11-20T09:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: Switching layouts &amp; Windows form doesn't work</title>
      <link>https://forums.autodesk.com/t5/net-forum/switching-layouts-windows-form-doesn-t-work/m-p/2118334#M76385</link>
      <description>Sorry, don't you need to dispose of the lock? Or does the transaction take care of that?</description>
      <pubDate>Tue, 20 Nov 2007 22:52:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/switching-layouts-windows-form-doesn-t-work/m-p/2118334#M76385</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-11-20T22:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: Switching layouts &amp; Windows form doesn't work</title>
      <link>https://forums.autodesk.com/t5/net-forum/switching-layouts-windows-form-doesn-t-work/m-p/2118335#M76386</link>
      <description>Good observation. You do.</description>
      <pubDate>Tue, 20 Nov 2007 22:54:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/switching-layouts-windows-form-doesn-t-work/m-p/2118335#M76386</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-11-20T22:54:12Z</dc:date>
    </item>
  </channel>
</rss>

