<?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: Creating first form application in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6457417#M35208</link>
    <description>Thanks, Giles! I'm pulling my hair out here trying to get it to work and tried everything I can think of but I don't think I possess the understanding of the net languages enough. I think therefore, I'll have to leave it and use a work around.&lt;BR /&gt;&lt;BR /&gt;Thanks again</description>
    <pubDate>Mon, 25 Jul 2016 12:25:11 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-07-25T12:25:11Z</dc:date>
    <item>
      <title>Creating first form application</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6453813#M35199</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created some simple code which takes some blocks,&amp;nbsp;draws&amp;nbsp;a polyline (and sweeps a solid along it) from the block to a line and groups all the objects into a individually grouped name. The code is below and works perfectly for what I want when using the command line. What I want to do now is apply this is a form but I don't have much of an idea as to how to start.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I want to create a modal win form, and have created the design in VBE but I'm not sure how to connect the code to the buttons etc and then launch it within cad.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My CAD code is here&lt;/P&gt;&lt;PRE&gt;[CommandMethod("CBC")]
        public static void ConnectBlocksToCurves()
        {
            var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            if (doc == null)
                return;
            var db = doc.Database;
            var ed = doc.Editor;
            // Get the block to connect

            try{
                                
            //Filter list to only choose blocks 
            TypedValue[] filterlist = new TypedValue[1];
            filterlist[0] = new TypedValue(0, "INSERT");

            SelectionFilter filter = new SelectionFilter(filterlist);
            PromptSelectionResult psr1 = ed.GetSelection(filter);

            if (psr1.Status != PromptStatus.OK)
                return;

            SelectionSet psrSet = psr1.Value;
        
            // Define gully depth

            PromptDoubleOptions pdo = new PromptDoubleOptions("\nSelect gully depth to invert (mm)");
            pdo.AllowArbitraryInput = true;
            pdo.AllowNone = false;
            pdo.Keywords.Add("600");
            pdo.Keywords.Add("750");
            pdo.UseDefaultValue = true;
            pdo.Keywords.Default = "600";
                

            PromptDoubleResult res = ed.GetDouble(pdo);
            if (res.Status != PromptStatus.OK)
            return;
            double depth = res.Value / 1000; // Converts depth to m

            // Get the curve to connect it to

            var peo2 = new PromptEntityOptions("\nSelect the curve");
            peo2.SetRejectMessage("\nMust be a curve.");
            peo2.AddAllowedClass(typeof(Curve), false);
            var per2 = ed.GetEntity(peo2);
            if (per2.Status != PromptStatus.OK)
                return;


            //Specify connection pipe diameter
            PromptDoubleOptions pdo1 = new PromptDoubleOptions("\nSpecify pipe diameter (mm)");
            pdo1.AllowNone = false;
            pdo1.AllowZero = false;
            PromptDoubleResult pdr1 = ed.GetDouble(pdo1);

            if (pdr1.Status != PromptStatus.OK)
                return;

            double dia = pdr1.Value / 1000;

            var cId = per2.ObjectId;

            ed.WriteMessage("\nFound {0} references. ", psrSet.Count);


            
            
            using (var tr = db.TransactionManager.StartTransaction())
            {

                var c = tr.GetObject(cId, OpenMode.ForRead) as Curve;
                var bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                var btr = (BlockTableRecord)tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForRead);

                //Sort blocks based on distance along string
ObjectIdCollection ids = psr1.Value.GetObjectIds();
                                var sorted = new BlockReference[ids.Count];
                
                for (int i = 0; i &amp;lt; ids.Count; i++)
                {
                    sorted[i] = tr.GetObject(ids[i], OpenMode.ForRead) as BlockReference;
                    Polyline3d pl = new Polyline3d();
                    btr.AppendEntity(pl);
                    tr.ConnectBlockToCurve(btr, sorted[i], c, depth, pl);//Call extension to draw a temporary polyline from the block to the curve

                    //Create temp cirlc with which to sweep
                    
                    Circle circ = new Circle();
                    circ.Center = pl.StartPoint;
                    circ.Diameter = dia;


                    //Create sweep options
                    SweepOptionsBuilder sob = new SweepOptionsBuilder();

                    //Sweep Alignment
                    sob.Align = SweepOptionsAlignOption.AlignSweepEntityToPath;

                    //Sweep base point
                    sob.BasePoint = pl.StartPoint;

                    //Profile rotates to folow path

                    sob.Bank = true;

                    Entity ent;

                    Solid3d sol = new Solid3d();

                    sol.CreateSweptSolid(
                        circ,
                        pl,
                        sob.ToSweepOptions()
                        );
                    ent = sol;


                    btr.AppendEntity(ent);

                    tr.AddNewlyCreatedDBObject(ent, true);

                    pl.Erase(true);

                    // Create group and add items

                    //Check gd is empty or not
                    
                    gd.UpgradeOpen();
                    Group grp = new Group("3D Drainage Elements", true);

                    string grpName = "Group" + i.ToString();
                                          
                   ObjectId grpID = gd.SetAt(grpName, grp);
                   
                    
                    tr.AddNewlyCreatedDBObject(grp, true);
                    grp.Append(sorted[i].ObjectId);
                    grp.Append(ent.ObjectId);


                };
            

                    tr.Commit();

                }
            
            }catch(System.Exception ex){
                System.Windows.Forms.MessageBox.Show(ex.Message,"Error");
           }

            }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My form is here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void depthBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void blocks_Click(object sender, EventArgs e)
        {

        }

        private void curves_Click(object sender, EventArgs e)
        {

        }

        private void diaBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void go_Click(object sender, EventArgs e)
        {

        }

                
        
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for reading.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2016 07:58:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6453813#M35199</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-22T07:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: Creating first form application</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6453938#M35200</link>
      <description>&lt;P&gt;As an example of what I have tried already, this is what I have in the block select button:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;private PromptSelectionResult blocks_Click(object sender, EventArgs e)
        {
            var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            var ed = doc.Editor;
            //Filter list to only choose blocks 
            TypedValue[] filterlist = new TypedValue[1];
            filterlist[0] = new TypedValue(0, "INSERT");

            SelectionFilter filter = new SelectionFilter(filterlist);
            PromptSelectionResult psr1 = ed.GetSelection(filter);
            return psr1;

        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the only way I can think of to&amp;nbsp;store the results of clicking the button, but this gives an error in the form code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;this&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;.blocks.Click += &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;new&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; System.&lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;EventHandler&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;this&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;.blocks_Click);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;[Error: has the wrong return type]&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2016 09:49:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6453938#M35200</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-22T09:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: Creating first form application</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6454002#M35201</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An event handler must return 'void'.&lt;/P&gt;
&lt;P&gt;You should create a property in the Form2 class and set its value from the event hadler, so, you can access it outside the Fom2 class.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        public SelectionSet BlockSelection { get; private set; }

        private void blocks_Click(object sender, EventArgs e)
        {
            var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            var ed = doc.Editor;
            //Filter list to only choose blocks 
            TypedValue[] filterlist = new TypedValue[1];
            filterlist[0] = new TypedValue(0, "INSERT");

            SelectionFilter filter = new SelectionFilter(filterlist);
            PromptSelectionResult psr1 = ed.GetSelection(filter);
            if (psr1.Status == PromptStatus.OK)
                BlockSelection = psr1.Value;
             else
                BlockSelection = null;
        }&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Jul 2016 10:51:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6454002#M35201</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-07-22T10:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: Creating first form application</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6454139#M35202</link>
      <description>Fantastic. Thank you. That's another one solved.&lt;BR /&gt;&lt;BR /&gt;Could I also ask how you would pass data from the main code into the form designer code?&lt;BR /&gt;&lt;BR /&gt;The reason being is that I have a number of blocks within the block table. I have created the list of blocks without issue but I want to create a listbox for each block within the form.&lt;BR /&gt;&lt;BR /&gt;I tried to create a class called BlockList within Form2 but when I use the class in the form I get the error 'The type 'System.Windows.Forms.Form' has no property named 'BlockList'.</description>
      <pubDate>Fri, 22 Jul 2016 12:32:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6454139#M35202</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-22T12:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creating first form application</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6454854#M35203</link>
      <description>&lt;P&gt;One way is to add a parameter to the Form2 constructor and pass it the block list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the Form2 partial class:&lt;/P&gt;
&lt;PRE&gt;public partial class Form2 : Form

{
    public Form2(BlockTableRecord[] blockList)
    {
        this.listbox1.DataSource = blockList;
        this.listbox1.DisplayMember = "Name";
    }

    public BlockTableRecord SelectedBlock
    {
        get { return this.listbox1.SelectedItem; }
    }

    // ...
}&lt;/PRE&gt;
&lt;P&gt;In the 'main code' (assuming blockList is a BlockTablerecord array):&lt;/P&gt;
&lt;PRE&gt;Form2 dialog = new Form2(blockList);
DialogResult result = AcAp.ShowModalDialog(dialog);
if (result = DailogResult.OK)
{
    BlockTableRecord btr = dialog.SelectedBlock;
    // ...
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2016 17:48:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6454854#M35203</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-07-22T17:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: Creating first form application</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6457000#M35204</link>
      <description>&lt;P&gt;Morning,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My block list actually a list string, but I tried to adapt the code you provided as per the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public Form3(List&amp;lt;string&amp;gt; blocklist)
        {

            var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            if (doc == null)
                return;
            var db = doc.Database;
            using (var tr = db.TransactionManager.StartTransaction())
            {
                var bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                List&amp;lt;string&amp;gt; retVal = new List&amp;lt;string&amp;gt;();
                foreach (ObjectId objId in bt)
                {
                    BlockTableRecord btr = (BlockTableRecord)objId.GetObject(OpenMode.ForRead);
                    if ((btr.XrefStatus == XrefStatus.NotAnXref)
                    &amp;amp;&amp;amp; !btr.IsAnonymous &amp;amp;&amp;amp; !btr.IsLayout &amp;amp;&amp;amp; !btr.IsDependent)
                    {
                        string bloName = btr.Name;
                        retVal.Add(bloName);
                    }
                }
                retVal.Sort();


                this.blockList1.DataSource = retVal;
                this.blockList1.DisplayMember = "Name"; 
                
                tr.Commit();
                       
            } 

        }

        public string SelectedBlock
        {
            get { return this.blockList1.SelectedItem.ToString(); }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I ran the code, it didn't populate the blockList1. I was also unsure what the last section you wrote does, or where it should be located? Does this little section affect the population of block names in blockList1?&lt;/P&gt;&lt;PRE&gt;Form2 dialog = new Form2(blockList);
DialogResult result = AcAp.ShowModalDialog(dialog);
if (result = DailogResult.OK)
{
    BlockTableRecord btr = dialog.SelectedBlock;
    // ...
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apologies for my naiveté.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 07:30:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6457000#M35204</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-25T07:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating first form application</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6457246#M35205</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the type of the collection passed to the constructor is List&amp;lt;string&amp;gt;, just do this in the Windows.Form part:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;public Form3(List&amp;lt;string&amp;gt; blocklist)
{
    foreach (string s in blocklist)
    {
        this.blockList1.items.Add(s);
    }
}&lt;BR /&gt;&lt;BR /&gt;public string SelectedBlock
{
    get { return this.blockList1.SelectedItem.ToString(); }
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the calling class (AutoCAD part):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
if (doc == null)
    return;
var db = doc.Database;
List&amp;lt;string&amp;gt; retVal = new List&amp;lt;string&amp;gt;();
using (var tr = db.TransactionManager.StartTransaction())
{
    var bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
    foreach (ObjectId objId in bt)
    {
        BlockTableRecord btr = (BlockTableRecord)objId.GetObject(OpenMode.ForRead);
        if ((btr.XrefStatus == XrefStatus.NotAnXref)
            &amp;amp;&amp;amp; !btr.IsAnonymous &amp;amp;&amp;amp; !btr.IsLayout &amp;amp;&amp;amp; !btr.IsDependent)
        {
            string bloName = btr.Name;
            retVal.Add(bloName);
        }
    }
    retVal.Sort();
    tr.Commit();   
}
	
Form3 dialog = new Form3(retVal);
DialogResult result = AcAp.ShowModalDialog(dialog);
if (result = DailogResult.OK)
{
    BlockTableRecord btr = dialog.SelectedBlock;
    // ...
}&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jul 2016 10:41:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6457246#M35205</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-07-25T10:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating first form application</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6457290#M35206</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Thanks for your help so far and sorry to keep pestering. I'm just struggling to understand the 'pass the constructor' bit. I have written the code which successfully grabs all the blocks in a drawing and populates the List&amp;lt;String&amp;gt;. I just don't know how this string gets to the public Form3()... section.</description>
      <pubDate>Mon, 25 Jul 2016 10:52:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6457290#M35206</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-25T10:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating first form application</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6457327#M35207</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The upper snipet is tyring to show how to separate the AutoCAD business concern and the Windows User Interface one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On the User Interface part:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;use the string list passed to the constructor to populate the ListBox&lt;/LI&gt;
&lt;LI&gt;expose the ListBox selected item&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On the AutoCAD part:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;build the block names list&lt;/LI&gt;
&lt;LI&gt;create a new instance of the UI passing it the block names list&lt;/LI&gt;
&lt;LI&gt;show the dialog and get DialogResult&lt;/LI&gt;
&lt;LI&gt;get the selected item in dialog and use it&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 11:19:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6457327#M35207</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-07-25T11:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Creating first form application</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6457417#M35208</link>
      <description>Thanks, Giles! I'm pulling my hair out here trying to get it to work and tried everything I can think of but I don't think I possess the understanding of the net languages enough. I think therefore, I'll have to leave it and use a work around.&lt;BR /&gt;&lt;BR /&gt;Thanks again</description>
      <pubDate>Mon, 25 Jul 2016 12:25:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6457417#M35208</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-25T12:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Creating first form application</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6457477#M35209</link>
      <description>&lt;P&gt;Here's a simple working example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Form1 class:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using System.Collections.Generic;
using System.Windows.Forms;

namespace SimpleDialogSample
{
    public partial class Form1 : Form
    {
        /// &amp;lt;summary&amp;gt;
        /// Creates a new instance of Form1
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="blockNames"&amp;gt;List of strings used to populate the list box&amp;lt;/param&amp;gt;
        public Form1(List&amp;lt;string&amp;gt; blockNames)
        {
            InitializeComponent();

            // populate the list box with blockNames contents
            foreach (string name in blockNames)
            {
                listBox1.Items.Add(name);
            }
        }

        /// &amp;lt;summary&amp;gt;
        /// Gets the selected name
        /// &amp;lt;/summary&amp;gt;
        public string SelectedName
        {
            get { return listBox1.SelectedItem.ToString(); }
        }
    }
}
&lt;/PRE&gt;
&lt;P&gt;The AutoCAD command class&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using System.Collections.Generic;

namespace SimpleDialogSample
{
    public class Commands
    {
        /// &amp;lt;summary&amp;gt;
        /// Shows a dialog to select a block name
        /// &amp;lt;/summary&amp;gt;
        [CommandMethod("CMD1")]
        public void Cmd1()
        {
            Database db = Application.DocumentManager.MdiActiveDocument.Database;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                // build the block names list
                BlockTable blockTable = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                List&amp;lt;string&amp;gt; names = new List&amp;lt;string&amp;gt;();
                foreach (ObjectId id in blockTable)
                {
                    BlockTableRecord btr = (BlockTableRecord)tr.GetObject(id, OpenMode.ForRead);
                    if (!(btr.IsLayout || btr.IsAnonymous || btr.IsFromExternalReference || btr.IsDependent))
                    {
                        names.Add(btr.Name);
                    }

                }

                // create a new instance of Form1 passing it the block names list
                Form1 dialog = new Form1(names);

                // show the dialog and get the result
                if (Application.ShowModalDialog(dialog) == System.Windows.Forms.DialogResult.OK)
                {
                    string blockName = dialog.SelectedName;
                    Application.ShowAlertDialog($"{blockName} {blockTable[blockName]}");
                }
                tr.Commit();
            }
        }
    }
}
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 12:52:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6457477#M35209</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-07-25T12:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: Creating first form application</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6457723#M35210</link>
      <description>Thanks so much, Giles! I have finally got it working on my form. Just one final thing, if I may? Hypothetically, if I wanted to bring in two List&amp;lt;strings&amp;gt;, how would I initiate Form3 to use both these variables, without creating two instances of the form?</description>
      <pubDate>Mon, 25 Jul 2016 14:54:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6457723#M35210</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-25T14:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: Creating first form application</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6458170#M35211</link>
      <description>&lt;P&gt;The Form3 constructor may have 2 (or as many as needed) parameters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;public Form1(List&amp;lt;string&amp;gt; list1, List&amp;lt;string&amp;gt; list2)&lt;BR /&gt;{&lt;BR /&gt;    initializeComponents();&lt;BR /&gt;&lt;BR /&gt;    // populate the controls with list1 and list2&lt;BR /&gt;}&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jul 2016 17:47:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6458170#M35211</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-07-25T17:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: Creating first form application</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6459450#M35212</link>
      <description>&lt;P&gt;Perfect. Thank you very much for your help. Much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll leave you in peace now &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2016 09:47:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-first-form-application/m-p/6459450#M35212</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-26T09:47:39Z</dc:date>
    </item>
  </channel>
</rss>

