Conditionally hidding elemnts

I need to show/hide a table in the document.
Of course I can make empty table and use this.
But it is more simple to use the construction like
[IF]
TABLE
[END IF]
Is it possible or not?

Hello
Thanks for your inquiry. Yes of course it is possible. If you need to conditionally show/hide part of content in your document, then you should consider using IF fields. For instance, please see the attached template. If you press Alt+F9 you will see field codes. If condition is true you will see the first text if false the second. Here is a simple code I used for testing:

Document doc = new Document("in.doc");
doc.MailMerge.Execute(new string[]
{
    "test"
}, new object[]
{
    "true"
});
doc.Save("out.doc");

Hope this approach could help you.
In additional, you can do not use mergefields in IF fields at all. I put a mergefield just to demonstrate how IF fields work.
Please follow the link to learn more about IF fields:
https://support.microsoft.com/en-us/office/field-codes-if-field-9f79e82f-e53b-4ff5-9d2c-ae3b22b7eb5e

Best regards,

I’ve read it.
And this is not that I want. It puts only text depends on condition not the elements.

Hello
Thanks for your inquiry. You can put anything you want inside your IF field (paragraphs, tables etc).
Best regards,

Can you give an example where table or image inside IF?

Hello
Thanks for your inquiry. Please see the attached template.
Best regards,

Ok, I did it. But I have taken a strange result.
In the result I see the data only after clicking alt+F9.
See template and report in attachments.

Hi
Thank you for additional information. Have you called UpdateFields method? Maybe in your case it is enough just call UpdateFields() to evaluate IF field.
https://docs.aspose.com/words/net/update-fields/
Best regards,

Thanks. It helps.