.net-core-3.0 - ListView clear() 防止显示新内容
问题描述
以下代码在框架 4.7.2 中运行良好
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
listView1.View = View.List;
listView1.Items.Clear();
listView1.Items.Add("A");
listView1.Items.Add("B");
listView1.Items.Add("C");
}
}
但是在 .Net Core 3 中, .clear() 的存在会导致其他项目不显示。
[更新]我应该包括以下内容
private void InitializeComponent()
{
System.Windows.Forms.ListViewItem listViewItem4 = new System.Windows.Forms.ListViewItem("");
this.listView1 = new System.Windows.Forms.ListView();
this.Column1 = new System.Windows.Forms.ColumnHeader();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
//
// listView1
//
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.Column1});
this.listView1.FullRowSelect = true;
this.listView1.GridLines = true;
this.listView1.HideSelection = false;
this.listView1.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
listViewItem4});
this.listView1.Location = new System.Drawing.Point(4, 7);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(849, 316);
this.listView1.TabIndex = 1;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
//
// Column1
//
this.Column1.Name = "Column1";
this.Column1.Text = "Name";
this.Column1.Width = 500;
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(3, 329);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(850, 265);
this.richTextBox1.TabIndex = 3;
this.richTextBox1.Text = "";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(3, 610);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(753, 23);
this.textBox1.TabIndex = 4;
//
// button1
//
this.button1.Location = new System.Drawing.Point(778, 609);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(74, 22);
this.button1.TabIndex = 5;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(865, 661);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.listView1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
// does nothing
}
解决方案
我有
listview1.View = View.Details
它需要是
listview1.View = View.List
推荐阅读
- string - 如何在 Scala 中将棋子与字符串分开?
- c# - 我用 DI 注入的服务有很多方法。有没有办法让这些容易找到?
- java - 如何在 Spark SQL Java 中将 CSV 类型字符串转换为数据框?
- spring - 无法创建简单的spring Boot Gateway api
- angular - 找出 Angular 项目中使用的更改事件的 Typescript 类型
- javascript - 如何用 Jest Javascript React Native 模拟“替换”功能?
- php - 如何使用 PHP 或 JavaScript 获取特定条件的当前 URL?
- delphi - Delphi 无效的类类型转换
- java - 哪种数据类型可用于在 Hibernate/jpa 中创建主键变量?
- java - 如何将输出从 java 到 .txt 文件。?JAVA