我的Windows窗體名稱叫「主登錄」無法從「BillingSystem.Presentation.MasterLogin」轉換爲「System.Windows.Forms.Form中」
public partial class MasterLogin : UserControl
當我通過這種形式爲「Program.cs中」,這裏示出了象
個錯誤1爲 最好重載方法匹配誤差 'System.Windows.Forms.Application.Run(System.Windows.Forms.Form中)' 具有 一些無效參數
我Program.cs中的代碼如下
using BillingSystem.Presentation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using BillingSystem.Reports;
namespace BillingSystem
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MasterLogin()); //usercontrol ---Error here
}
}
}
用戶控件無法作爲應用程序啓動。您可以將該控件放在窗體上(我們稱之爲'MasterLoginForm'),然後調用'Application.Run(new MasterLoginForm());' – Nino
您需要一個表單而不是usercontrol來啓動應用程序。 – Maarten
用戶控件存在於窗體中,應用程序啓動窗體。添加一個表單,將你的用戶控件添加到表單中,啓動表單。 – Liam