Analysis of abnormal phenomena of ListView in C #
The main content of this article is "Analysis of ListView anomalies in C#". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "Analysis of ListView anomalies in C#".
In the load event of the form:
This.listView1.Columns.Add ("id", 120, HorizontalAlignment.Left); / / add this.listView1.Columns.Add ("name", 120, HorizontalAlignment.Left) in one step; / add this.listView1.Columns.Add ("age", 120, HorizontalAlignment.Left) in one step; / / add this.listView1.BeginUpdate () in one step / / data update, UI temporarily suspended until EndUpdate drawing control, which can effectively avoid flicker and greatly improve loading speed for (int I = 0; I < 10; iTunes +) / / add 10 rows of data {ListViewItem lvi = new ListViewItem (); lvi.ImageIndex = I / / display item I icon in imageList lvi.Text = "subitem" + I; lvi.SubItems.Add ("column 2, row" + I + "row"); lvi.SubItems.Add (column 3, line "+ I +"); this.listView1.Items.Add (lvi) by binding with imageList } this.listView1.EndUpdate (); / / finish the data processing, and draw the UI interface at one time. ListView1.View = View.Details
The above code feels normal, with three columns of headers: id,name,age, and then adds 10 rows of data. However, when I started the program, I found that listview was empty. When debugging, it is found that after the execution of this.listView1.Items.Add (lvi); (at this time iTunes 0), iTune1 will not be executed again. Wait for the logic, and form's load event function jumps out.
At this point, I believe you have a deeper understanding of the "Analysis of ListView anomalies in C#". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!