closing InfoPath

S

sadhana

How can I close InfoPath form through code under submit_button click?

I tried this.Application.Quit(true)
and this.Application.Close();
but these are not working.
 
K

K.Ramana Reddy(GGK Tech)

Hi,

Use below code in submit_button click,

Application.ActiveWindow.Close(false); ( this is in jscript)
 
S

Shiva (GGK Tech)

Hi,

You can try below line code in your button code:
XDocument.View.Window.Close(true);

Hope this helps you.
 
S

sadhana

Hi,
@Shiva,
I tried this code, but it is not working.
It is giving the error the name "XDocument" does not exist in the current
context.

Thanks
 
S

sadhana

Hi,
@Ramana Reddy,

could you tell me how to convert it into C#, because I already wrote some
code in C# under Button_Click event and I want to add the code for closing
the form as the last line.

Thanks
 
K

K.Ramana Reddy(GGK Tech)

Hi,

Use below code,
thisXDocument.View.Window.Close(true); (this is in c#)
 
S

sadhana

Do I need to import any other namespaces??
Because I am not getting 'thisXDocument' in the intellisense window.
 
K

K.Ramana Reddy(GGK Tech)

Hi,

When you create the infopath project in visual studio, by default
"thisXDocument" is defined in following function.

public void _Startup(Application app, XDocument doc)
{
thisXDocument = doc;
thisApplication = app;

// You can add additional initialization code here.
}

there is no need to include specific namespaces.
 
S

sadhana

I am writing this code in VSTA

i mean, Tools->Programming->VSTA

here I only find public void InternalStartup()
{
} function in this FormCode.cs file.

Am I missing any thing?
 
Top