本文整理汇总了C#中System.Windows.Forms.ListView.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# ListView.Dispose方法的具体用法?C# ListView.Dispose怎么用?C# ListView.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ListView
的用法示例。
在下文中一共展示了ListView.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectedIndexCollectionTest_RemoveTest_VirtualMode
public void SelectedIndexCollectionTest_RemoveTest_VirtualMode ()
{
ListView listview = new ListView ();
listview.VirtualListSize = 5;
listview.RetrieveVirtualItem += ListViewRetrieveVirtualItemHandler;
listview.VirtualMode = true;
CreateVirtualItems (5);
// Force to create the handle
listview.CreateControl ();
listview.SelectedIndices.Add (0);
listview.SelectedIndices.Add (2);
listview.SelectedIndices.Add (4);
Assert.AreEqual (3, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_RemoveTest#1");
Assert.AreEqual (true, listview.Items [0].Selected, "SelectedIndexCollectionTest_RemoveTest#2");
Assert.AreEqual (true, listview.Items [2].Selected, "SelectedIndexCollectionTest_RemoveTest#3");
Assert.AreEqual (true, listview.Items [4].Selected, "SelectedIndexCollectionTest_RemoveTest#4");
Assert.AreEqual (0, listview.SelectedIndices [0], "SelectedIndexCollectionTest_RemoveTest#5");
Assert.AreEqual (2, listview.SelectedIndices [1], "SelectedIndexCollectionTest_RemoveTest#6");
Assert.AreEqual (4, listview.SelectedIndices [2], "SelectedIndexCollectionTest_RemoveTest#7");
listview.SelectedIndices.Remove (2);
Assert.AreEqual (2, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_RemoveTest#8");
Assert.AreEqual (false, listview.Items [2].Selected, "SelectedIndexCollectionTest_RemoveTest#9");
Assert.AreEqual (0, listview.SelectedIndices [0], "SelectedIndexCollectionTest_RemoveTest#10");
Assert.AreEqual (4, listview.SelectedIndices [1], "SelectedIndexCollectionTest_RemoveTest#11");
listview.SelectedIndices.Remove (0);
Assert.AreEqual (1, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_RemoveTest#12");
Assert.AreEqual (false, listview.Items [0].Selected, "SelectedIndexCollectionTest_RemoveTest#13");
Assert.AreEqual (4, listview.SelectedIndices [0], "SelectedIndexCollectionTest_RemoveTest#14");
listview.SelectedIndices.Remove (4);
Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_RemoveTest#15");
Assert.AreEqual (false, listview.Items [4].Selected, "SelectedIndexCollectionTest_RemoveTest#16");
// Remove an already removed index
listview.SelectedIndices.Remove (0);
Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_RemoveTest#17");
Assert.AreEqual (false, listview.Items [0].Selected, "SelectedIndexCollectionTest_RemoveTest#18");
listview.Dispose ();
}
示例2: SelectedItemCollectionTest_Indexer2
public void SelectedItemCollectionTest_Indexer2 ()
{
ListView lvw = new ListView ();
ListViewItem lvi1 = new ListViewItem ("A");
lvi1.Name = "A name";
lvi1.Selected = true;
ListViewItem lvi2 = new ListViewItem ("B");
lvi2.Name = "Same name";
lvi2.Selected = false;
ListViewItem lvi3 = new ListViewItem ("C");
lvi3.Name = "Same name";
lvi3.Selected = true;
ListViewItem lvi4 = new ListViewItem ("D");
lvi4.Name = String.Empty;
lvi4.Selected = true;
ListViewItem lvi5 = new ListViewItem ("E");
lvi5.Name = "E name";
lvi5.Selected = false;
lvw.Items.AddRange (new ListViewItem [] { lvi1, lvi2, lvi3, lvi4, lvi5 });
// Force to create the control
lvw.CreateControl ();
Assert.AreEqual (3, lvw.SelectedItems.Count, "#A1");
Assert.AreEqual (null, lvw.SelectedItems [String.Empty], "#A2");
Assert.AreEqual (null, lvw.SelectedItems [null], "#A3");
Assert.AreEqual (lvi1, lvw.SelectedItems ["A name"], "#A4");
Assert.AreEqual (lvi1, lvw.SelectedItems ["a NAME"], "#A5");
Assert.AreEqual (lvi3, lvw.SelectedItems ["Same name"], "#A6");
Assert.AreEqual (null, lvw.SelectedItems ["E name"], "#A7");
ListViewItem lvi6 = new ListViewItem ("F");
lvw.Items.Add (lvi6);
lvi6.Selected = true;
lvi6.Name = "F name";
Assert.AreEqual (4, lvw.SelectedItems.Count, "#B1");
Assert.AreEqual (lvi6, lvw.SelectedItems ["F name"], "#B2");
lvw.Dispose ();
}
示例3: SelectedIndexCollectionTest_IndexOfTest_VirtualMode
public void SelectedIndexCollectionTest_IndexOfTest_VirtualMode ()
{
ListView listview = new ListView ();
listview.VirtualListSize = 4;
listview.RetrieveVirtualItem += ListViewRetrieveVirtualItemHandler;
listview.VirtualMode = true;
CreateVirtualItems (4);
// Force to create the handle
listview.CreateControl ();
listview.SelectedIndices.Add (0);
listview.SelectedIndices.Add (3);
listview.SelectedIndices.Add (2);
Assert.AreEqual (3, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_IndexOfTest#1");
Assert.AreEqual (0, listview.SelectedIndices.IndexOf (0), "SelectedIndexCollectionTest_IndexOfTest#2");
Assert.AreEqual (1, listview.SelectedIndices.IndexOf (2), "SelectedIndexCollectionTest_IndexOfTest#3");
Assert.AreEqual (2, listview.SelectedIndices.IndexOf (3), "SelectedIndexCollectionTest_IndexOfTest#4");
Assert.AreEqual (-1, listview.SelectedIndices.IndexOf (1), "SelectedIndexCollectionTest_IndexOfTest#5");
Assert.AreEqual (-1, listview.SelectedIndices.IndexOf (99), "SelectedIndexCollectionTest_IndexOfTest#6");
Assert.AreEqual (-1, listview.SelectedIndices.IndexOf (-1), "SelectedIndexCollectionTest_IndexOfTest#7");
listview.Dispose ();
}
示例4: SelectedIndexCollectionTest_RemoveTest
public void SelectedIndexCollectionTest_RemoveTest ()
{
ListView listview = new ListView ();
listview.Items.Add ("A");
listview.SelectedIndices.Add (0);
listview.SelectedIndices.Remove (0);
Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_RemoveTest#1");
Assert.AreEqual (false, listview.Items [0].Selected, "SelectedIndexCollectionTest_RemoveTest#2");
// Force to create the handle
listview.CreateControl ();
listview.SelectedIndices.Add (0);
listview.SelectedIndices.Remove (0);
Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_RemoveTest#3");
Assert.AreEqual (false, listview.Items [0].Selected, "SelectedIndexCollectionTest_RemoveTest#4");
listview.Dispose ();
}
示例5: SelectedIndexCollectionTest_ClearTest_VirtualMode
public void SelectedIndexCollectionTest_ClearTest_VirtualMode ()
{
ListView listview = new ListView ();
listview.VirtualListSize = 3;
listview.RetrieveVirtualItem += ListViewRetrieveVirtualItemHandler;
listview.VirtualMode = true;
CreateVirtualItems (3);
// Force to create the handle
listview.CreateControl ();
listview.SelectedIndices.Add (2);
listview.SelectedIndices.Add (0);
Assert.AreEqual (2, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_ClearTest#1");
Assert.AreEqual (0, listview.SelectedIndices [0], "SelectedIndexCollectionTest_ClearTest#2");
Assert.AreEqual (2, listview.SelectedIndices [1], "SelectedIndexCollectionTest_ClearTest#3");
Assert.AreEqual (true, listview.Items [0].Selected, "SelectedIndexCollectionTest_ClearTest#4");
Assert.AreEqual (false, listview.Items [1].Selected, "SelectedIndexCollectionTest_ClearTest#5");
Assert.AreEqual (true, listview.Items [2].Selected, "SelectedIndexCollectionTest_ClearTest#6");
listview.SelectedIndices.Clear ();
Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_ClearTest#5");
Assert.AreEqual (false, listview.Items [0].Selected, "SelectedIndexCollectionTest_ClearTest#6");
Assert.AreEqual (false, listview.Items [1].Selected, "SelectedIndexCollectionTest_ClearTest#7");
Assert.AreEqual (false, listview.Items [2].Selected, "SelectedIndexCollectionTest_ClearTest#8");
listview.Dispose ();
}
示例6: SelectedIndexCollectionTest_IndexOfTest
public void SelectedIndexCollectionTest_IndexOfTest ()
{
ListView listview = new ListView ();
ListViewItem item1 = listview.Items.Add ("A");
ListViewItem item2 = listview.Items.Add ("B");
ListViewItem item3 = listview.Items.Add ("C");
ListViewItem item4 = listview.Items.Add ("D");
listview.SelectedIndices.Add (0);
listview.SelectedIndices.Add (3);
listview.SelectedIndices.Add (2);
Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_IndexOfTest#1");
Assert.AreEqual (-1, listview.SelectedIndices.IndexOf (item1.Index), "SelectedIndexCollectionTest_IndexOfTest#2");
Assert.AreEqual (-1, listview.SelectedIndices.IndexOf (item3.Index), "SelectedIndexCollectionTest_IndexOfTest#3");
Assert.AreEqual (-1, listview.SelectedIndices.IndexOf (item4.Index), "SelectedIndexCollectionTest_IndexOfTest#4");
Assert.AreEqual (-1, listview.SelectedIndices.IndexOf (item2.Index), "SelectedIndexCollectionTest_IndexOfTest#5");
// Force to create the control
listview.CreateControl ();
Assert.AreEqual (3, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_IndexOfTest#6");
Assert.AreEqual (0, listview.SelectedIndices.IndexOf (item1.Index), "SelectedIndexCollectionTest_IndexOfTest#7");
Assert.AreEqual (1, listview.SelectedIndices.IndexOf (item3.Index), "SelectedIndexCollectionTest_IndexOfTest#8");
Assert.AreEqual (2, listview.SelectedIndices.IndexOf (item4.Index), "SelectedIndexCollectionTest_IndexOfTest#9");
Assert.AreEqual (-1, listview.SelectedIndices.IndexOf (item2.Index), "SelectedIndexCollectionTest_IndexOfTest#10");
listview.Dispose ();
}
示例7: SelectedIndexCollectionTest_AddTest_VirtualMode
public void SelectedIndexCollectionTest_AddTest_VirtualMode ()
{
ListView listview = new ListView ();
listview.VirtualListSize = 5;
listview.RetrieveVirtualItem += ListViewRetrieveVirtualItemHandler;
listview.VirtualMode = true;
CreateVirtualItems (5);
int n = listview.SelectedIndices.Add (0);
Assert.AreEqual (-1, n, "SelectedIndexCollectionTest_AddTest#1");
Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_AddTest#2");
Assert.AreEqual (false, listview.Items [0].Selected, "SelectedIndexCollectionTest_AddTest#3");
// Force to create the handle
// Selection state should remain empty
listview.CreateControl ();
Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_AddTest#4");
Assert.AreEqual (false, listview.Items [0].Selected, "SelectedIndexCollectionTest_AddTest#5");
n = listview.SelectedIndices.Add (0);
Assert.AreEqual (1, n, "SelectedIndexCollectionTest_AddTest#5");
Assert.AreEqual (1, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_AddTest#6");
Assert.AreEqual (0, listview.SelectedIndices [0], "SelectedIndexCollectionTest_AddTest#7");
Assert.AreEqual (true, listview.Items [0].Selected, "SelectedIndexCollectionTest_AddTest#8");
// Make sure the collection keeps them sorted
listview.SelectedIndices.Add (4);
n = listview.SelectedIndices.Add (2);
Assert.AreEqual (3, n, "SelectedIndexCollectionTest_AddTest#9");
Assert.AreEqual (3, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_AddTest#10");
Assert.AreEqual (0, listview.SelectedIndices [0], "SelectedIndexCollectionTest_AddTest#11");
Assert.AreEqual (2, listview.SelectedIndices [1], "SelectedIndexCollectionTest_AddTest#12");
Assert.AreEqual (4, listview.SelectedIndices [2], "SelectedIndexCollectionTest_AddTest#13");
Assert.AreEqual (true, listview.Items [0].Selected, "SelectedIndexCollectionTest_AddTest#14");
Assert.AreEqual (true, listview.Items [2].Selected, "SelectedIndexCollectionTest_AddTest#15");
Assert.AreEqual (true, listview.Items [4].Selected, "SelectedIndexCollectionTest_AddTest#16");
// Add the item twice
n = listview.SelectedIndices.Add (0);
Assert.AreEqual (3, n, "SelectedIndexCollectionTest_AddTest#17");
Assert.AreEqual (3, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_AddTest#18");
listview.Dispose ();
}
示例8: ImageList_ListView_Disposed
public void ImageList_ListView_Disposed ()
{
ListView lv = new ListView ();
lv.View = View.Details;
ImageList small = new ImageList ();
lv.SmallImageList = small;
ImageList large = new ImageList ();
lv.LargeImageList = large;
ColumnHeader col = new ColumnHeader ();
lv.Columns.Add (col);
lv.Dispose ();
Assert.IsNull (col.ImageList);
}
示例9: Width_ListView_Disposed
public void Width_ListView_Disposed ()
{
ListView lv = new ListView ();
lv.View = View.Details;
ColumnHeader col = new ColumnHeader ();
lv.Columns.Add (col);
lv.Dispose ();
col.Width = 10;
Assert.AreEqual (10, col.Width);
}
示例10: SelectedIndexCollectionTest_AddTest
public void SelectedIndexCollectionTest_AddTest ()
{
ListView listview = new ListView ();
listview.Items.Add ("A");
int n = listview.SelectedIndices.Add (0);
Assert.AreEqual (0, n, "SelectedIndexCollectionTest_AddTest#1");
Assert.AreEqual (true, listview.Items [0].Selected, "SelectedIndexCollectionTest_AddTest#2");
// Force to create the handle
listview.CreateControl ();
Assert.AreEqual (1, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_AddTest#4");
n = listview.SelectedIndices.Add (0);
Assert.AreEqual (1, n, "SelectedIndexCollectionTest_AddTest#5");
Assert.AreEqual (1, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_AddTest#6");
Assert.AreEqual (true, listview.Items [0].Selected, "SelectedIndexCollectionTest_AddTest#7");
listview.Dispose ();
}
示例11: TextAlign_ListView_Disposed
public void TextAlign_ListView_Disposed ()
{
ListView lv = new ListView ();
lv.View = View.Details;
ColumnHeader col = new ColumnHeader ();
lv.Columns.Add (col);
lv.Dispose ();
col.TextAlign = HorizontalAlignment.Right;
Assert.AreEqual (HorizontalAlignment.Right, col.TextAlign);
}
示例12: Text_ListView_Disposed
public void Text_ListView_Disposed ()
{
ListView lv = new ListView ();
lv.View = View.Details;
ColumnHeader col = new ColumnHeader ();
lv.Columns.Add (col);
lv.Dispose ();
col.Text = "whatever";
Assert.AreEqual ("whatever", col.Text);
}
示例13: Index_ListView_Disposed
public void Index_ListView_Disposed ()
{
ListView lv = new ListView ();
lv.View = View.Details;
ColumnHeader colA = new ColumnHeader ();
lv.Columns.Add (colA);
ColumnHeader colB = new ColumnHeader ();
lv.Columns.Add (colB);
lv.Dispose ();
Assert.AreEqual (-1, colA.Index, "#1");
Assert.AreEqual (-1, colB.Index, "#2");
}
示例14: DisposeTest
public void DisposeTest ()
{
ListView lv = new ListView ();
lv.View = View.Details;
lv.LargeImageList = new ImageList ();
lv.SmallImageList = new ImageList ();
ListViewItem lvi = new ListViewItem ();
lv.Items.Add (lvi);
ColumnHeader col = new ColumnHeader ();
lv.Columns.Add (col);
lv.Dispose ();
Assert.IsNull (lvi.ListView, "#A1");
Assert.IsNull (col.ListView, "#A2");
Assert.IsNull (lv.LargeImageList, "#B1");
Assert.IsNull (lv.SmallImageList, "#B2");
Assert.IsNull(lv.StateImageList, "#B3");
}
示例15: SelectedIndexCollectionTest_ClearTest
public void SelectedIndexCollectionTest_ClearTest ()
{
ListView listview = new ListView ();
listview.Items.Add ("A");
listview.Items.Add ("B");
listview.Items.Add ("C");
listview.SelectedIndices.Add (0);
listview.SelectedIndices.Add (2);
// Nothing if handle hasn't been created
listview.SelectedIndices.Clear ();
Assert.AreEqual (true, listview.Items [0].Selected, "SelectedIndexCollectionTest_ClearTest#2");
Assert.AreEqual (false, listview.Items [1].Selected, "SelectedIndexCollectionTest_ClearTest#3");
Assert.AreEqual (true, listview.Items [2].Selected, "SelectedIndexCollectionTest_ClearTest#4");
// Force to create the handle
listview.CreateControl ();
listview.SelectedIndices.Add (0);
listview.SelectedIndices.Add (2);
listview.SelectedIndices.Clear ();
Assert.AreEqual (0, listview.SelectedIndices.Count, "SelectedIndexCollectionTest_ClearTest#5");
Assert.AreEqual (false, listview.Items [0].Selected, "SelectedIndexCollectionTest_ClearTest#6");
Assert.AreEqual (false, listview.Items [1].Selected, "SelectedIndexCollectionTest_ClearTest#7");
Assert.AreEqual (false, listview.Items [2].Selected, "SelectedIndexCollectionTest_ClearTest#8");
listview.Dispose ();
}