1

HI,

I'm new to Windows form app and trying to build one prototype app. I've designed a data entry form and coded the business logic. Now, I'm trying to open the data entry form from my welcome form. But every time I run "Welcome" form, my data entry form runs ( it's created before welcome form ) . Where can I set the form's order of execution ?

Here is the form1 code,

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;

namespace PrototypeApp
{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void button3_Click(object sender, EventArgs e)
    {
        string pdfTemplate = "C:\\app\\End_Of_Project_Client_Evaluation_Template.pdf";
        string newFile = "C:\\app\\End_Of_Project_Client_Evaluation_Template_update.pdf";

        PdfReader reader = new PdfReader(pdfTemplate);
        PdfStamper pdfStamper = new PdfStamper(reader, new FileStream(newFile, FileMode.Create));


        AcroFields fields = pdfStamper.AcroFields;

        fields.SetField("client", txtClient.Text);
        fields.SetField("project", txtProject.Text);
        fields.SetField("project_area", txtArea.Text);
        fields.SetField("project_no", txtLandProjectNo.Text);
        fields.SetField("suggestions", txtSuggestions.Text);
        fields.SetField("project_strength", txtStrengths.Text);
        fields.SetField("other_suggestions", txtComments.Text);


        pdfStamper.FormFlattening = false;

        // close the pdf
        pdfStamper.Close();

        MessageBox.Show("Pdf document successfully updated!!");

    }

}

}

Ris
  • 1,152
  • 7
  • 29
  • 63

1 Answers1

2

In your solution you have a file called Program.cs, open it and change the following line:

 Application.Run(new Form1());

to

 Application.Run(new WelcomeForm());

where WelcomeForm is the name of your welcome UI class. This change will make you welcome form to show up when you start the application, after that you can add some code to start the other form when you want.

Adrian Fâciu
  • 12,414
  • 3
  • 53
  • 68
  • Adrian,Perfect.. this is what I was looking for :) One more thing, After linking the form1 in welcome screen menu, when I click on form1 it's opening in new window. How to open in welcome screen itself below menu. Do I need to place some frame kind of control to achieve this ? – Ris Jan 05 '11 at 06:36
  • 1
    @Rishi, one easy and dirty solution would be to add all of the controls into the Welcome Screen and just resize the window. You set the height so that only the menu is visible and on click you extend the height so that everything gets visible. – Adrian Fâciu Jan 05 '11 at 06:42