Search code examples
c#winformspropertygrid

How do I get the parent form name from property grid node? C#


I have a property grid which is hosted on a normal winForm. Within the property grid I have a node. Within a node I have a list of drop down items. When the user selects a particular value I want to be able to load a pre-existing dialog box which is called from an inherited method. I need to pass the Parent IWin32Window into the method. Is there a way of getting the instance name of the parent window from wtihin my property grid node property?

I'm using the PromptandCreateVariable method, which is part of the IDTSVariableService interface.

The code I have so far is:

private IServiceProvider _sp = null;                            

public IServiceProvider ServiceProvider
{
    get { return _sp; }
    set { _sp = value; }


    [Category("Local Path"),
    Description("Specifies local Path")]
    public Variable LocalPath
    {
        get
        {
           //do something
           IDtsVariableService _dtsVariableService = 
               _sp.GetService(typeof(IDtsVariableService)) as IDtsVariableService;

           Variable newVariable =
               _dtsVariableService.PromptAndCreateVariable(
                   this, null, "LocalPath", "User", typeof(string));
        }
        set
        {
            //do something
        }
    }
 }

Solution

  • I was solved this by just creating an instance of IWin32Window within my class and passing it into the PromptAndCreateVariable method.