I have program that displays a "Loading" Winform when a button is pressed and disappears once the script needing to be run is complete.
When the button is pressed, the new form 'appears' however it displays none of the form information, such as the Logo and labels - only a blank/grey box. I've attempted changing the background colour and altering images however it is still displaying as blank form.
What I find to be most confusing is that this blank form displayed only appears blank when a specific CS. file is called within the button press; PDFMerge.CombineMultiblePDFs. If I try to display the Loading form within a different part of the program, e.g. when a different button is pressed, the form loads correctly as planned with all content.
Here is the blank form being displayed:
Here is the correct form being displayed on a different button or different form
Here is the code I am calling which displays the "blank" Winform.
loadingPDF.Show(); // Show the loading form string fileDate = DateTime.Now.ToString("dd-MM-yy"); string fileTime = DateTime.Now.ToString("HH.mm.ss"); string outcomeFolder = outputFolder; string outputFile = "Combined Folder " + fileDate + " @ " + fileTime + ".pdf"; string outputFileName = Path.Combine(outcomeFolder, outputFile); // combines the file name, output path selected and the yes / no for pagebreaks. PDFMerge.CombineMultiplePDFs(sourceFiles, outputFileName); loadingPDF.Hide(); // Hide the loading form If I replace the PDFMerge.Combine with a different within CS file, the Loading form displays correctly, which leads me to believe the issue is laying with the PDFMerge and when it is being called. Below is the code used within the PDFMerge;
public class PDFMerge { public static void CombineMultiplePDFs(String[] fileNames, string outFile) { try { int pageOffset = 0; int f = 0; Document document = null; PdfCopy writer = null; while (f < fileNames.Length) { // Create a reader for a certain document PdfReader reader = new PdfReader(fileNames[f]); reader.ConsolidateNamedDestinations(); // Retrieve the total number of pages int n = reader.NumberOfPages; pageOffset += n; if (f == 0) { // Creation of a document-object document = new Document(reader.GetPageSizeWithRotation(1)); // Create a writer that listens to the document writer = new PdfCopy(document, new FileStream(outFile, FileMode.Create)); // Open the document document.Open(); } // Add content for (int i = 0; i < n;) { ++i; if (writer != null) { PdfImportedPage page = writer.GetImportedPage(reader, i); writer.AddPage(page); } } PRAcroForm form = reader.AcroForm; if (form != null && writer != null) { //writer.CopyAcroForm(reader); writer.Close(); } f++; } // Close the document if (document != null) { document.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } I don't see what could be causing the clash with the form display, perhaps the Form isn't loading on time but i don't see how it works with some features and not with others. Any advice regarding the issue would be greatly appreciated. Thank you
Update 1: Additional code requested, Here is the code used to LoadingPDF form. I used Winforms to create the content on the form:
public partial class LoadingPDF : Form { public LoadingPDF() { InitializeComponent(); } private void LoadingPDF_Load(object sender, EventArgs e) { // } } Creating instance of the loadingPDF form in the file selection form
// Declaring the 'loading' form when files are being combined. LoadingPDF loadingPDF = new LoadingPDF(); 
