我正在创建一个简单的 GUI 程序来管理优先级。
我已经成功地添加了将项目添加到列表框的功能。现在我想将该项目添加到 C# 中称为 List<> 的内容中。Python中存在这样的东西吗?
例如,在 C# 中,要将项目添加到列表视图,我首先要创建:
List<Priority> priorities = new List<Priority>();
Run Code Online (Sandbox Code Playgroud)
...然后创建以下方法:
void Add()
{
if (listView1.SelectedItems.Count > 0)
{
MessageBox.Show("Please make sure you have no priorities selected!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (txt_Priority.ReadOnly == true) { MessageBox.Show("Please make sure you refresh fields first!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); }
else
{
if ((txt_Priority.Text.Trim().Length == 0)) { MessageBox.Show("Please enter the word!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); }
else
{
Priority p = new Priority();
p.Subject = txt_Priority.Text;
if …Run Code Online (Sandbox Code Playgroud)