public void ColumnHeaderCollection_IndexOf_Empty_ReturnsFalse()
        {
            var listView   = new ListView();
            var collection = new ListView.ColumnHeaderCollection(listView);

            Assert.Equal(-1, collection.IndexOf(new ColumnHeader()));
            Assert.Equal(-1, collection.IndexOf(null));
        }
        public void ColumnHeaderCollection_IListIndexOf_Empty_ReturnsMinusOne()
        {
            var   listView   = new ListView();
            IList collection = new ListView.ColumnHeaderCollection(listView);

            Assert.Equal(-1, collection.IndexOf(new ColumnHeader()));
            Assert.Equal(-1, collection.IndexOf(new object()));
            Assert.Equal(-1, collection.IndexOf(null));
        }
        public void ColumnHeaderCollection_IndexOf_Invoke_ReturnsExpected()
        {
            var listView   = new ListView();
            var collection = new ListView.ColumnHeaderCollection(listView);
            var header     = new ColumnHeader();

            collection.Add(header);

            Assert.Equal(0, collection.IndexOf(header));
            Assert.Equal(-1, collection.IndexOf(new ColumnHeader()));
            Assert.Equal(-1, collection.IndexOf(null));
        }
Exemple #4
0
        public static void ExportToCsv(string output, ObjectListView List)
        {
            ListView.ColumnHeaderCollection properties = null;

            if (List != null && List.Items.Count >= 1)
            {
                properties = (List.Columns);
            }

            using (CsvFileWriter writer = new CsvFileWriter(output))
            {
                // Set Column titles
                CsvRow title = new CsvRow();
                foreach (OLVColumn p in properties)
                {
                    title.Add(p.Text);
                }
                writer.WriteRow(title);

                // Fill data rows
                foreach (ListViewItem o in List.Items)
                {
                    CsvRow row = new CsvRow();
                    foreach (OLVColumn p in properties)
                    {
                        row.Add(o.SubItems[properties.IndexOf(p)].Text);
                    }
                    writer.WriteRow(row);
                }

                writer.Close();
            }
        }
        public void ColumnHeaderCollection_IndexOfKey_Empty_ReturnsFalse()
        {
            using var listView = new ListView();
            var collection = new ListView.ColumnHeaderCollection(listView);

            Assert.Equal(-1, collection.IndexOfKey("text"));
            Assert.Equal(-1, collection.IndexOf(null));
        }
 public int IndexOf(ColumnHeaderEx item) => list.IndexOf(item);