gpt4 book ai didi

c# - c#中的窗体加载

转载 作者:太空宇宙 更新时间:2023-11-03 16:33:53 27 4
gpt4 key购买 nike

我正在编写一个程序来读取输入文件,然后将名称列表显示给用户。我的编码如下:

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();
}

我不确定为什么我的表单没有加载。我在最后一条语句激活表单时出错,而且我不确定如何加载表单。我在互联网上尝试了数百种不同的东西。谁能帮忙。

谢谢

最佳答案

我想您也可以放弃对 InitialiseComponent 和 Activate 的调用。这些将由设计者代码和事件的自然顺序处理。应该使您的代码更轻一些。

关于c# - c#中的窗体加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9858201/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com