2
我正在寫一個程序,它讀取輸入文件,然後向用戶顯示名稱列表。 我編碼如下:c窗口窗體加載#
Read the txt file
Store the data in a list
then call a method userint.add_names(names); //where names is a list containing first name and last name.
Created a new method in userint.cs as follows:
internal void add_localvars(List<names> name)
{
userinter userinterface = new userinter();
InitializeComponent();
listbox1.DataSource = name;
listbox1.DisplayMember = "first_name";
userInterface.Activate();
userinterface.Show();
}
我不知道爲什麼,是不是我裝形式。我在上次聲明中激活表單時出錯,而且我不確定如何加載表單。我在互聯網上嘗試了一百種不同的東西。任何人都可以請幫忙。
謝謝
向我們顯示錯誤消息。 – 2012-03-25 05:56:11
在WindowsFormsApplication2.exe中發生未處理的異常'System.NullReferenceException'類型 附加信息:未將對象引用設置爲對象的實例。 – 2012-03-25 05:57:14
你初始化了'userInterface'嗎? – 2012-03-25 05:58:45