예제 #1
0
        public Form1()
        {
            InitializeComponent();

            //Show details with two columns
            lv.View = View.Details;
            lv.Columns.Add("First Item", -2, HorizontalAlignment.Center);
            lv.Columns.Add("Sub Item", -2, HorizontalAlignment.Center);

            //Add individual items to the first stored list
            lvw1 = new LvItems();
            lvw1.Add("1     I belong to LC1");
            lvw1.Add("2     I belong to LC1");
            lvw1.Add("3     I belong to LC1");

            //Add an item to the first list that has a sub item
            ListViewItem k = new ListViewItem();

            k.Text = "4     Parent Item";
            k.SubItems.Add("Sub Item 1");
            lvw1.Add(k);

            //Add items to the second stored list
            lvw2 = new LvItems();
            lvw2.Add("1   I belong to LC2");
            lvw2.Add("2   I belong to LC2");
            lvw2.Add("3   I belong to LC2");

            lv.Items.AddRange(lvw1.Items);
        }
예제 #2
0
 private void cmdSwap_Click(object sender, System.EventArgs e)
 {
     SwapList = SwapList == lvw2 ? lvw1 : lvw2;
     lv.Items.Clear();
     lv.Items.AddRange(SwapList.Items);
 }