2011-01-05 48 views
1

嗨,Windows窗體應用程序:如何設置表單命令?

我是新來的Windows窗體應用程序,並試圖建立一個原型應用程序。我設計了一個數據錄入表單並對業務邏輯進行了編碼。現在,我試圖從我的歡迎表單打開數據輸入表單。但每次運行「歡迎」表單時,我的數據輸入表單都會運行(它是在歡迎表單之前創建的)。我可以在哪裏設置表單的執行順序?

這裏是Form1代碼,

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!!"); 

    } 

} 

}

回答

2

在你的解決方案,您有一個名爲的Program.cs文件,打開它,並更改以下行:

Application.Run(new Form1()); 

Application.Run(new WelcomeForm()); 

其中,WelcomeForm是歡迎UI類的名稱。此更改將使您在啓動應用程序時顯示歡迎表單,之後您可以添加一些代碼以在需要時啓動其他表單。

+0

阿德里安,完美..這就是我一直在尋找:)另外一件事,在歡迎屏幕菜單中鏈接form1後,當我點擊form1它在新窗口中打開。如何在菜單下方的歡迎屏幕中打開。我是否需要放置一些框架類型的控件來實現這一點? – Rishi 2011-01-05 06:36:36

+1

@Rishi,一個簡單而骯髒的解決方案是將所有控件添加到歡迎屏幕中,並調整窗口大小。您可以設置高度,以便只顯示菜單,單擊時可以擴展高度,以便顯示所有內容。 – 2011-01-05 06:42:52

相關問題