/* add two new columns */ listView1.Columns.Clear(); listView1.Columns.Add( "Name", 150, HorizontalAlignment.Left ); listView1.Columns.Add( "Detail", 100, HorizontalAlignment.Left ); listView1.View = View.Details; /* enable row selection */ listView1.HideSelection = false; listView1.FullRowSelect = true; /* add three items */ ListViewItem lvi = new ListViewItem( "Item 1" ); listView1.Items.Add( lvi ); lvi.SubItems.Add( "Detail 1" ); lvi.Selected = true; lvi = new ListViewItem( "Item 2" ); listView1.Items.Add( lvi ); lvi.SubItems.Add( "Detail 2" ); lvi = new ListViewItem( "Item 3" ); listView1.Items.Add( lvi ); lvi.SubItems.Add( "Detail 3" ); listView1.Focus();Output:
Microsoft AX 2012, X++, C#, SQL server, SSRS, Java, JavaFX, Oracle, PL/SQL, Delphi - codes examples, step-by-step tutorials, experiences.
Monday, September 10, 2018
C# - How add items to ListView with two columns
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment