I am following up to my question yesterday with some progress. The request is still the same. I wish to have a popup during my file creation (created from a menu command) after the file is created and populated with values from two files. The get and set variables work as well as a popup window, but I can't seem to get the DataCard to show in the window. The examples online all have an existing form already and update that. I am trying to use a form within the class library.

 

The line view = (IEdmCardView63)destFolder.CreateCardView(fileID, 0, 40, 300, (EdmCallback)this); is incorrect and I want to know how I should be going about doing this. My code is below and works for everything except showing the card.

 

using System;
using System.IO;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
//using System.Threading.Tasks;
using EdmLib;
using System.Drawing;
using Microsoft.VisualBasic;
using System.Windows.Forms;
namespace ClassLibrary2
{
    public class Class1 : IEdmAddIn5
    {
        public void GetAddInInfo(ref EdmAddInInfo poInfo, IEdmVault5 poVault, IEdmCmdMgr5 poCmdMgr)
        {
            //Specify information to display in the add-in's Properties dialog box   
            poInfo.mbsAddInName = "Menu command sample";
            poInfo.mbsCompany = "SOLIDWORKS Corporation";
            poInfo.mbsDescription = "Adds menu command items";
            poInfo.mlAddInVersion = 1;
            //Specify the minimum required version of SOLIDWORKS Enterprise PDM  
            poInfo.mlRequiredVersionMajor = 10;
            poInfo.mlRequiredVersionMinor = 0;
            //Register a menu command  
            poCmdMgr.AddCmd(100, "Inspection Request (New C#)", (int)EdmMenuFlags.EdmMenu_OnlySingleSelection);
        }


        IEdmCardView63 view;


        public void OnCmd(ref EdmCmd poCmd, ref Array ppoData)
        {
            if (poCmd.meCmdType == EdmCmdType.EdmCmd_Menu) //This makes sure the addin was called on a menu right click  
            {
                if (poCmd.mlCmdID == 100) //This makes sure the menu command ID was 100, which means your addin was the one called  
                {
                    //Let's get moving, it's our turn!  
                    IEdmVault12 myVault = (IEdmVault12)poCmd.mpoVault; //Cast the vault to an Iedmvault12 object for latest functionality  
                    string Mymessage = null;//instantiate a string message  
                    //string StrID = null;//instantiate the ID of the object  
                    if ((((EdmCmdData)ppoData.GetValue(0)).mlObjectID1) != 0) //mlObjectID1 will be 0 if a folder was selected and the ID of the file if a file was selected during a menu command  
                    {
                        //Mymessage = Mymessage + "File: (ID=";
                        IEdmFile5 myfile = (IEdmFile10)myVault.GetObject(EdmObjectType.EdmObject_File, (((EdmCmdData)ppoData.GetValue(0)).mlObjectID1));//Get the file object  


                        string fileNoExt = Path.GetFileNameWithoutExtension(myfile.Name);
                        
                        IEdmEnumeratorVariable10 myvars = default(IEdmEnumeratorVariable10); //Set the enumeratorvariable object  
                        myvars = (IEdmEnumeratorVariable10)myfile.GetEnumeratorVariable(); //Cast the enumeratorvariable object to the file  
                        object CreatedBy = null; //Create a variable to hold the model no.  
                        object Desc1 = null;
                        object Desc2 = null;
                        object Rev = null;


                        myvars.GetVar("CreatedBy", "@", out CreatedBy); //Use the GetVar method  
                        myvars.GetVar("CAD_Description", "@", out Desc1);
                        myvars.GetVar("CAD_Description1", "@", out Desc2);
                        myvars.GetVar("CAD_Revision", "@", out Rev);


                        myvars.CloseFile(false); //Always close the file when done accessing card variables to avoid runtime errors  
                                                 //Mymessage = Mymessage + "File ID: " + myfile.ID + System.Environment.NewLine; //Create a message with the File ID  


                        Mymessage = Mymessage + "CreatedBy: " + CreatedBy + System.Environment.NewLine; //Add the model no. variable  
                        Mymessage = Mymessage + "Description: " + Desc1 + System.Environment.NewLine;
                        Mymessage = Mymessage + "Description1: " + Desc2 + System.Environment.NewLine;
                        Mymessage = Mymessage + "Revision: " + Rev + System.Environment.NewLine;


                        MessageBox.Show(Mymessage); //Show the message box!  


                        MessageBox.Show("Get template path");
                        string templPath = @"C:\SeanVault\Templates\template.item.cvd";
                        string newPath = @"C:\SeanVault\Inspection Files";
                        string filename = fileNoExt + " Rev " + Rev.ToString() + ".insp";
                        IEdmFile5 templateFile = default(IEdmFile5);
                        IEdmFolder5 srcFolder = null;
                        templateFile = myVault.GetFileFromPath(templPath, out srcFolder);


                        MessageBox.Show("Get destination path");
                        IEdmFolder5 destFolder = default(IEdmFolder5);
                        destFolder = myVault.GetFolderFromPath(newPath);
                        if (destFolder == null)
                            return;




                        int fileID = 0;
                        fileID = destFolder.CopyFile(templateFile.ID, srcFolder.ID, 0, filename, (int)EdmCopyFlag.EdmCpy_Simple);
                        
                        Interaction.MsgBox("Copied file successfully to new file with ID, " + fileID);


                                                                        
                        IEdmFile5 newFile = default(IEdmFile5);
                        IEdmFile5 itemFile = default(IEdmFile5);


                        newPath = newPath + "\\" + filename;


                        //Search for file with .item extension
                        IEdmSearch5 Search = default(IEdmSearch5);
                        Search = (IEdmSearch5)myVault.CreateUtility(EdmUtility.EdmUtil_Search);


                        Search.FindFiles = true;
                        //Search.StartFolderID = 102; //Regular Items ID
                        Search.FileName = fileNoExt + ".item";
                        IEdmSearchResult5 Result = default(IEdmSearchResult5);
                        


                        Result = Search.GetFirstResult();
                        object StockingType = null; //Create a variable to hold the model no. 
                        if (Result != null)
                        {
                            MessageBox.Show("Result exists. Begin! Path = " + Result.Path);
                            itemFile = myVault.GetFileFromPath(Result.Path, out srcFolder);
                            IEdmEnumeratorVariable10 itemVars = default(IEdmEnumeratorVariable10); //Set the enumeratorvariable object  
                            itemVars = (IEdmEnumeratorVariable10)itemFile.GetEnumeratorVariable(); //Cast the enumeratorvariable object to the file  
                            //breaks
                            itemVars.GetVar("ITEM_StockingType", "", out StockingType); //Use the GetVar method


                            myvars.CloseFile(false); //Always close the file when done accessing card variables to avoid runtime errors  
                                                     //Mymessage = Mymessage + "File ID: " + myfile.ID + System.Environment.NewLine; //Create a message with the File ID  
                        }


                        newFile = myVault.GetFileFromPath(newPath, out srcFolder);
                        //update variables
                        IEdmEnumeratorVariable10 myNewVars = default(IEdmEnumeratorVariable10); //Set the enumeratorvariable object  
                        myNewVars = (IEdmEnumeratorVariable10)newFile.GetEnumeratorVariable(); //Cast the enumeratorvariable object to the file  
                        
                        myNewVars.SetVar("ITEM_RevisionNumber", "", Rev.ToString());
                        myNewVars.SetVar("ITEM_DescriptionLine1", "", Desc1.ToString());
                        myNewVars.SetVar("ITEM_DescriptionLine2", "", Desc2.ToString());


                        if (StockingType.ToString() != null)
                        {
                            myNewVars.SetVar("ITEM_StockingType", "", StockingType.ToString());
                        }


                        myvars.CloseFile(false); //Always close the file when done accessing card variables to avoid runtime errors  
                                                 //Mymessage = Mymessage + "File ID: " + myfile.ID + System.Environment.NewLine; //Create a message with the File ID  


                        // Create a new instance of the form.
                        Form form1 = new Form();
                        // Create two buttons to use as the accept and cancel buttons.
                        Button button1 = new Button();
                        Button button2 = new Button();


                        // Create the card view interface 
                        //BREAKS HERE
                        view = (IEdmCardView63)destFolder.CreateCardView(fileID, 0, 40, 300, (EdmCallback)this);
                        if (view == null)
                        {
                            Interaction.MsgBox("The file does not have a card.");
                            return;
                        }


                        // Set input focus to the first control in the card
                        view.SetFocus(0);


                        // Enable all controls in the card
                        view.Update(EdmCardViewUpdateType.EdmCvut_EnableCtrl);


                        // Get the size needed to display the card 
                        int width = 0;
                        int height = 0;
                        view.GetCardSize(out width, out height);


                        // Resize the form window to make room for the card 
                        form1.Width = (width + 100);
                        form1.Height = (height + 400);
                        view.ShowWindow(true);


                        //SaveCard.Enabled = false;




                        // Set the text of button1 to "OK".
                        button1.Text = "OK";
                        // Set the position of the button on the form.
                        button1.Location = new Point(10, 10);
                        // Set the text of button2 to "Cancel".
                        button2.Text = "Cancel";
                        // Set the position of the button based on the location of button1.
                        button2.Location
                           = new Point(button1.Left, button1.Height + button1.Top + 10);
                        // Make button1's dialog result OK.
                        button1.DialogResult = DialogResult.OK;
                        // Make button2's dialog result Cancel.
                        button2.DialogResult = DialogResult.Cancel;
                        // Set the caption bar text of the form.   
                        form1.Text = "My Dialog Box";


                        // Define the border style of the form to a dialog box.
                        form1.FormBorderStyle = FormBorderStyle.FixedDialog;
                        // Set the accept button of the form to button1.
                        form1.AcceptButton = button1;
                        // Set the cancel button of the form to button2.
                        form1.CancelButton = button2;
                        // Set the start position of the form to the center of the screen.
                        form1.StartPosition = FormStartPosition.CenterScreen;


                        // Add button1 to the form.
                        form1.Controls.Add(button1);
                        // Add button2 to the form.
                        form1.Controls.Add(button2);


                        // Display the form as a modal dialog box.
                        form1.ShowDialog();


                        // Determine if the OK button was clicked on the dialog box.
                        if (form1.DialogResult == DialogResult.OK)
                        {
                            // Display a message box indicating that the OK button was clicked.
                            MessageBox.Show("The OK button on the form was clicked.");
                            // Optional: Call the Dispose method when you are finished with the dialog box.
                            form1.Dispose();
                        }
                        else
                        {
                            // Display a message box indicating that the Cancel button was clicked.
                            MessageBox.Show("The Cancel button on the form was clicked.");
                            // Optional: Call the Dispose method when you are finished with the dialog box.
                            form1.Dispose();
                        }


                        //Check-in new file
                        newFile.UnlockFile(0,"Created and checked-in with Sean's API.");


                        //myvars.SetVar("CAD_Weight","@", "This Worked");


                        //Mymessage = Mymessage + "File name: " + ((EdmCmdData)ppoData.GetValue(0)).mbsStrData1 + System.Environment.NewLine; //Add the file name  


                    }
                }
            }
        }
    }
}

Categories: API∕Macros

Comments
Last comment By: Sean Donnelly   Wed, 26 Apr 2017 19:39:10 GMT
Re: Follow-up to Pop-up PDM DataCard C#

That line breaks because you're not implementing the EdmCallback interface.

 

Change your class to; public class Class1 : IEdmAddIn5, EdmCallback

 

The compiler will complain that you're not implementing the interface so you'll need to add the required methods/properties. You can have VS do that for you.

By: Lee CS Young  Thu, 20 Apr 2017 19:43:09 GMT
Re: Follow-up to Pop-up PDM DataCard C#

I apologize for sounding dumb here but I'm still very new to this, how would I go about adding the required methods/properties. What should they properly look like? I updated the public class. I didn't realize I forgot that part, thanks!

By: Sean Donnelly  Thu, 20 Apr 2017 19:48:22 GMT
Re: Follow-up to Pop-up PDM DataCard C#

Don't apologize. We all started somewhere.

 

I am not sure what version you're using but you should see something like this;

 

You'll need these methods.

 

  public void SetModifiedFlag()
        {           
        }


        public void SetProgressPos(int lPos)
        {       
        }


        public void SetProgressRange(int lMin, int lMax)
        {       
        }


        public void SetStatusMessage(string bsMessage)
        {       
        }
By: Lee CS Young  Thu, 20 Apr 2017 20:00:23 GMT
Re: Follow-up to Pop-up PDM DataCard C#

Sean Donnelly wrote:

 

I am following up to my question yesterday with some progress. The request is still the same. I wish to have a popup during my file creation (created from a menu command) after the file is created and populated with values from two files. The get and set variables work as well as a popup window, but I can't seem to get the DataCard to show in the window. The examples online all have an existing form already and update that. I am trying to use a form within the class library.

 

The line view = (IEdmCardView63)destFolder.CreateCardView(fileID, 0, 40, 300, (EdmCallback)this); is incorrect and I want to know how I should be going about doing this. My code is below and works for everything except showing the card.

I suspect that passing a null handle for the parent windows is not acceptable:

 

view=(IEdmCardView63)destFolder.CreateCardView(fileID,0,40,300,(EdmCallback)this);

 

Try passing in form1.Handle instead of 0.

 

Also, it's always a good idea to boil your code down to the smallest possible example that displays the bad behavior, and then posting that to the forum.  No one wants to read through  two hundred lines of boilerplate UI creation code looking for problems. Often, the act of simplifying the code exposes the problem and you end up solving it yourself rather than waiting for responses from others.

By: Jim Sculley  Thu, 20 Apr 2017 20:01:10 GMT
Re: Follow-up to Pop-up PDM DataCard C#

when I do that I see this. I am creating a form within the class code, instead of as it's own class (I think i'm saying that correctly?)

By: Sean Donnelly  Thu, 20 Apr 2017 20:54:06 GMT
Re: Follow-up to Pop-up PDM DataCard C#

See below. It's still the same with the changes you are suggesting. The card just "shows up" in the background. Not on the actual dialog box. Updated code below.

 

 

using System;
using System.IO;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
//using System.Threading.Tasks;
using EdmLib;
using System.Drawing;
using Microsoft.VisualBasic;
using System.Windows.Forms;
namespace ClassLibrary2
{
    public class Class1 : IEdmAddIn5, EdmCallback
    {
        public void GetAddInInfo(ref EdmAddInInfo poInfo, IEdmVault5 poVault, IEdmCmdMgr5 poCmdMgr)
        {
            //Specify information to display in the add-in's Properties dialog box 
            poInfo.mbsAddInName = "Menu command sample";
            poInfo.mbsCompany = "SOLIDWORKS Corporation";
            poInfo.mbsDescription = "Adds menu command items";
            poInfo.mlAddInVersion = 1;
            //Specify the minimum required version of SOLIDWORKS Enterprise PDM 
            poInfo.mlRequiredVersionMajor = 10;
            poInfo.mlRequiredVersionMinor = 0;
            //Register a menu command 
            poCmdMgr.AddCmd(100, "Inspection Request (New C#)", (int)EdmMenuFlags.EdmMenu_OnlySingleSelection);
        }


        IEdmCardView63 view;


        public void OnCmd(ref EdmCmd poCmd, ref Array ppoData)
        {
            if (poCmd.meCmdType == EdmCmdType.EdmCmd_Menu) //This makes sure the addin was called on a menu right click 
            {
                if (poCmd.mlCmdID == 100) //This makes sure the menu command ID was 100, which means your addin was the one called 
                {
                    //Let's get moving, it's our turn! 
                    IEdmVault12 myVault = (IEdmVault12)poCmd.mpoVault; //Cast the vault to an Iedmvault12 object for latest functionality 
                    string Mymessage = null;//instantiate a string message 
                    //string StrID = null;//instantiate the ID of the object 
                    if ((((EdmCmdData)ppoData.GetValue(0)).mlObjectID1) != 0) //mlObjectID1 will be 0 if a folder was selected and the ID of the file if a file was selected during a menu command 
                    {
                        //Mymessage = Mymessage + "File: (ID=";
                        IEdmFile5 myfile = (IEdmFile10)myVault.GetObject(EdmObjectType.EdmObject_File, (((EdmCmdData)ppoData.GetValue(0)).mlObjectID1));//Get the file object 


                        string fileNoExt = Path.GetFileNameWithoutExtension(myfile.Name);
                       
                        IEdmEnumeratorVariable10 myvars = default(IEdmEnumeratorVariable10); //Set the enumeratorvariable object 
                        myvars = (IEdmEnumeratorVariable10)myfile.GetEnumeratorVariable(); //Cast the enumeratorvariable object to the file 
                        object CreatedBy = null; //Create a variable to hold the model no. 
                        object Desc1 = null;
                        object Desc2 = null;
                        object Rev = null;


                        myvars.GetVar("CreatedBy", "@", out CreatedBy); //Use the GetVar method 
                        myvars.GetVar("CAD_Description", "@", out Desc1);
                        myvars.GetVar("CAD_Description1", "@", out Desc2);
                        myvars.GetVar("CAD_Revision", "@", out Rev);


                        myvars.CloseFile(false); //Always close the file when done accessing card variables to avoid runtime errors 
                                                //Mymessage = Mymessage + "File ID: " + myfile.ID + System.Environment.NewLine; //Create a message with the File ID 


                        Mymessage = Mymessage + "CreatedBy: " + CreatedBy + System.Environment.NewLine; //Add the model no. variable 
                        Mymessage = Mymessage + "Description: " + Desc1 + System.Environment.NewLine;
                        Mymessage = Mymessage + "Description1: " + Desc2 + System.Environment.NewLine;
                        Mymessage = Mymessage + "Revision: " + Rev + System.Environment.NewLine;


                        MessageBox.Show(Mymessage); //Show the message box! 


                        MessageBox.Show("Get template path");
                        string templPath = @"C:\SeanVault\Templates\template.item.cvd";
                        string newPath = @"C:\SeanVault\Inspection Files";
                        string filename = fileNoExt + " Rev " + Rev.ToString() + ".insp";
                        IEdmFile5 templateFile = default(IEdmFile5);
                        IEdmFolder5 srcFolder = null;
                        templateFile = myVault.GetFileFromPath(templPath, out srcFolder);


                        MessageBox.Show("Get destination path");
                        IEdmFolder5 destFolder = default(IEdmFolder5);
                        destFolder = myVault.GetFolderFromPath(newPath);
                        if (destFolder == null)
                            return;




                        int fileID = 0;
                        fileID = destFolder.CopyFile(templateFile.ID, srcFolder.ID, 0, filename, (int)EdmCopyFlag.EdmCpy_Simple);
                       
                        Interaction.MsgBox("Copied file successfully to new file with ID, " + fileID);


                                                                       
                        IEdmFile5 newFile = default(IEdmFile5);
                        IEdmFile5 itemFile = default(IEdmFile5);


                        newPath = newPath + "\\" + filename;


                        //Search for file with .item extension
                        IEdmSearch5 Search = default(IEdmSearch5);
                        Search = (IEdmSearch5)myVault.CreateUtility(EdmUtility.EdmUtil_Search);


                        Search.FindFiles = true;
                        //Search.StartFolderID = 102; //Regular Items ID
                        Search.FileName = fileNoExt + ".item";
                        IEdmSearchResult5 Result = default(IEdmSearchResult5);
                       


                        Result = Search.GetFirstResult();
                        object StockingType = null; //Create a variable to hold the model no.
                        if (Result != null)
                        {
                            MessageBox.Show("Result exists. Begin! Path = " + Result.Path);
                            itemFile = myVault.GetFileFromPath(Result.Path, out srcFolder);
                            IEdmEnumeratorVariable10 itemVars = default(IEdmEnumeratorVariable10); //Set the enumeratorvariable object 
                            itemVars = (IEdmEnumeratorVariable10)itemFile.GetEnumeratorVariable(); //Cast the enumeratorvariable object to the file 
                            //breaks
                            itemVars.GetVar("ITEM_StockingType", "", out StockingType); //Use the GetVar method


                            myvars.CloseFile(false); //Always close the file when done accessing card variables to avoid runtime errors 
                                                    //Mymessage = Mymessage + "File ID: " + myfile.ID + System.Environment.NewLine; //Create a message with the File ID 
                        }


                        newFile = myVault.GetFileFromPath(newPath, out srcFolder);
                        //update variables
                        IEdmEnumeratorVariable10 myNewVars = default(IEdmEnumeratorVariable10); //Set the enumeratorvariable object 
                        myNewVars = (IEdmEnumeratorVariable10)newFile.GetEnumeratorVariable(); //Cast the enumeratorvariable object to the file 
                       
                        myNewVars.SetVar("ITEM_RevisionNumber", "", Rev.ToString());
                        myNewVars.SetVar("ITEM_DescriptionLine1", "", Desc1.ToString());
                        myNewVars.SetVar("ITEM_DescriptionLine2", "", Desc2.ToString());


                        if (StockingType.ToString() != null)
                        {
                            myNewVars.SetVar("ITEM_StockingType", "", StockingType.ToString());
                        }


                        myvars.CloseFile(false); //Always close the file when done accessing card variables to avoid runtime errors 
                                                //Mymessage = Mymessage + "File ID: " + myfile.ID + System.Environment.NewLine; //Create a message with the File ID 


                        // Create a new instance of the form.
                        Form form1 = new Form();
                        // Create two buttons to use as the accept and cancel buttons.
                        Button button1 = new Button();
                        Button button2 = new Button();


                        // Create the card view interface
                        //BREAKS HERE
                        view = (IEdmCardView63)destFolder.CreateCardView(fileID, 0, 40, 300, (EdmCallback)this);
                        if (view == null)
                        {
                            Interaction.MsgBox("The file does not have a card.");
                            return;
                        }


                        // Set input focus to the first control in the card
                        view.SetFocus(0);


                        // Enable all controls in the card
                        view.Update(EdmCardViewUpdateType.EdmCvut_EnableCtrl);


                        // Get the size needed to display the card
                        int width = 0;
                        int height = 0;
                        view.GetCardSize(out width, out height);


                        // Resize the form window to make room for the card
                        form1.Width = (width + 100);
                        form1.Height = (height + 400);
                        view.ShowWindow(true);


                        //SaveCard.Enabled = false;




                        // Set the text of button1 to "OK".
                        button1.Text = "OK";
                        // Set the position of the button on the form.
                        button1.Location = new Point(10, 10);
                        // Set the text of button2 to "Cancel".
                        button2.Text = "Cancel";
                        // Set the position of the button based on the location of button1.
                        button2.Location
                          = new Point(button1.Left, button1.Height + button1.Top + 10);
                        // Make button1's dialog result OK.
                        button1.DialogResult = DialogResult.OK;
                        // Make button2's dialog result Cancel.
                        button2.DialogResult = DialogResult.Cancel;
                        // Set the caption bar text of the form. 
                        form1.Text = "My Dialog Box";


                        // Define the border style of the form to a dialog box.
                        form1.FormBorderStyle = FormBorderStyle.FixedDialog;
                        // Set the accept button of the form to button1.
                        form1.AcceptButton = button1;
                        // Set the cancel button of the form to button2.
                        form1.CancelButton = button2;
                        // Set the start position of the form to the center of the screen.
                        form1.StartPosition = FormStartPosition.CenterScreen;


                        // Add button1 to the form.
                        form1.Controls.Add(button1);
                        // Add button2 to the form.
                        form1.Controls.Add(button2);


                        // Display the form as a modal dialog box.
                        form1.ShowDialog();


                        // Determine if the OK button was clicked on the dialog box.
                        if (form1.DialogResult == DialogResult.OK)
                        {
                            // Display a message box indicating that the OK button was clicked.
                            MessageBox.Show("The OK button on the form was clicked.");
                            // Optional: Call the Dispose method when you are finished with the dialog box.
                            form1.Dispose();
                        }
                        else
                        {
                            // Display a message box indicating that the Cancel button was clicked.
                            MessageBox.Show("The Cancel button on the form was clicked.");
                            // Optional: Call the Dispose method when you are finished with the dialog box.
                            form1.Dispose();
                        }


                        //Check-in new file
                        newFile.UnlockFile(0,"Created and checked-in with Sean's API.");


                        //myvars.SetVar("CAD_Weight","@", "This Worked");


                        //Mymessage = Mymessage + "File name: " + ((EdmCmdData)ppoData.GetValue(0)).mbsStrData1 + System.Environment.NewLine; //Add the file name 


                    }
                }
            }
        }
        public void SetModifiedFlag()
        {
            throw new NotImplementedException();
        }




        public void SetProgressPos(int lPos)
        {
            throw new NotImplementedException();
        }




        public void SetProgressRange(int lMin, int lMax)
        {
            throw new NotImplementedException();
        }




        public void SetStatusMessage(string bsMessage)
        {
            throw new NotImplementedException();
        }
    }
}
By: Sean Donnelly  Thu, 20 Apr 2017 21:11:11 GMT
Re: Follow-up to Pop-up PDM DataCard C#

You can cast the IntPtr directly to int, like this:

 

(int)form1.Handle

By: Jim Sculley  Fri, 21 Apr 2017 11:57:36 GMT
Re: Follow-up to Pop-up PDM DataCard C#

This worked! Thank you!

By: Sean Donnelly  Fri, 21 Apr 2017 13:46:59 GMT
Re: Follow-up to Pop-up PDM DataCard C#

Jim, I really appreciate all of the help! I have one more question if you know the answer. I'm trying to use the code below, but receive the following error. I'm trying to change/add information to the datacard and save. Thanks for all of the help!

 

if (form1.DialogResult == DialogResult.OK)
                        {
                            // Display a message box indicating that the OK button was clicked.
                            MessageBox.Show("The OK button on the form was clicked.");
                            view.SaveData();
                            // Optional: Call the Dispose method when you are finished with the dialog box.
                            form1.Dispose();
                        }

 

By: Sean Donnelly  Fri, 21 Apr 2017 14:17:01 GMT
Re: Follow-up to Pop-up PDM DataCard C#

My best guess is that calling SaveData on a form that has been closed (via the OK button) isn't allowed.  I have a card form for one of my add-ins that looks like this:

 

Note that Save and Done are separate.

By: Jim Sculley  Fri, 21 Apr 2017 18:01:30 GMT
Re: Follow-up to Pop-up PDM DataCard C#

How do you go about saving the data card view back to the file?

By: Sean Donnelly  Wed, 26 Apr 2017 19:39:10 GMT
You are not authorized to view this page No results found! Suggestions: Check spelling, try a different search, or browse topics below.