本文整理汇总了C#中System.Windows.Forms.ListView.Sort方法的典型用法代码示例。如果您正苦于以下问题:C# ListView.Sort方法的具体用法?C# ListView.Sort怎么用?C# ListView.Sort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ListView
的用法示例。
在下文中一共展示了ListView.Sort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ColumnSort
/// <summary>
/// call this from column click.
/// </summary>
/// <param name="lvs">an instance of listviewsorter</param>
/// <param name="lv">The lv.</param>
/// <param name="column">The column.</param>
/// <param name="forceorder">if set to a value, will sort by that all the time, otherwise will sort as normal</param>
public static void ColumnSort(ListViewSorter lvs, ListView lv, int column, SortOrder? forceorder = null)
{
try
{
lv.ListViewItemSorter = lvs;
if (!(lv.ListViewItemSorter is ListViewSorter))
return;
lvs = (ListViewSorter) lv.ListViewItemSorter;
}
catch (Exception)
{
return;
}
if (forceorder != null)
{
lv.Sorting = (SortOrder) forceorder;
}
else
{
//invert sorting
lv.Sorting = lv.Sorting == SortOrder.Ascending ? SortOrder.Descending : SortOrder.Ascending;
}
lvs.ByColumn = column;
lv.Sort();
}
示例2: sortColumn
public static void sortColumn(ListView listView, int column)
{
ListViewColumnSorter columnSorter = (ListViewColumnSorter)listView.ListViewItemSorter;
// Determine if clicked column is already the column that is being sorted.
if ( column == columnSorter.SortColumn )
{
// Reverse the current sort direction for this column.
if (columnSorter.Order == SortOrder.Ascending)
{
columnSorter.Order = SortOrder.Descending;
}
else
{
columnSorter.Order = SortOrder.Ascending;
}
}
else
{
// Set the column number that is to be sorted; default to ascending.
columnSorter.SortColumn = column;
columnSorter.Order = SortOrder.Ascending;
}
// Perform the sort with these new sort options.
listView.Sort();
}
示例3: doSort
void doSort(ListView lv)
{
lv.Sort();
if (lv.Items.Count > 0)
lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
if (lv.SelectedItems.Count > 0)
lv.EnsureVisible(lv.SelectedIndices[0]);
}
示例4: ColumnSort
public static int ColumnSort(ListView list, ColumnClickEventArgs e, int currColumn)
{
if (e.Column != currColumn)
{
currColumn = e.Column;
if (list.Sorting == SortOrder.None && currColumn == 0)
list.Sorting = SortOrder.Descending;
else
list.Sorting = SortOrder.Ascending;
}
else
list.Sorting = list.Sorting == SortOrder.Ascending ? SortOrder.Descending : SortOrder.Ascending;
list.Sort();
list.ListViewItemSorter = new ListViewItemComparer(e.Column, list.Sorting);
return currColumn;
}
示例5: RefreshProcessList
protected override void RefreshProcessList(ListView listView, bool showNonManaged)
{
listView.Items.Clear();
WindowsDebugger debugger = (WindowsDebugger)DebuggerService.CurrentDebugger;
Process currentProcess = Process.GetCurrentProcess();
foreach (Process process in Process.GetProcesses()) {
try {
// Prevent attaching to our own process.
if (currentProcess.Id != process.Id) {
ProcessListViewItem item = new ProcessListViewItem(process, debugger);
if (showNonManaged || item.IsManaged) {
item.Tag = process;
listView.Items.Add(item);
}
}
} catch (Win32Exception) {
// Do nothing.
}
}
listView.Sort();
}
示例6: ListViewSort
public static void ListViewSort(ListView listView, ref int sortColumn, int column)
{
if (column != sortColumn)
{
sortColumn = column;
listView.Sorting = SortOrder.Ascending;
}
else
{
if (listView.Sorting == SortOrder.Ascending)
listView.Sorting = SortOrder.Descending;
else
listView.Sorting = SortOrder.Ascending;
}
//?
// http://msdn.microsoft.com/en-us/library/ms996467.aspx
listView.ListViewItemSorter = new ListViewItemComparer(column, listView.Sorting);
listView.Sort();
}
示例7: listView_OnColumnClick
public static void listView_OnColumnClick(object sender, System.Windows.Forms.ColumnClickEventArgs e, ListView listView)
{
ListViewSorter sorter = (ListViewSorter)listView.ListViewItemSorter;
if (!(listView.ListViewItemSorter is ListViewSorter))
return;
if (sorter.LastSort == e.Column)
{
if (listView.Sorting == SortOrder.Ascending)
listView.Sorting = SortOrder.Descending;
else
listView.Sorting = SortOrder.Ascending;
}
else
{
listView.Sorting = SortOrder.Descending;
}
sorter.ByColumn = e.Column;
listView.Sort();
}
示例8: SortColumn
public void SortColumn(ColumnClickEventArgs e, ListView listview)
{
// Determine if clicked column is already the column that is being sorted.
if (e.Column == this.SortColumnAmount)
{
// Reverse the current sort direction for this column.
this.Order = Order == SortOrder.Ascending ? SortOrder.Descending : SortOrder.Ascending;
}
else
{
// Set the column number that is to be sorted; default to ascending.
this.SortColumnAmount = e.Column;
this.Order = SortOrder.Ascending;
}
// Perform the sort with these new sort options.
listview.Sort();
}
示例9: SetSortOrderProperty
/// <summary>
/// Sets static property for SortOrder property.
/// </summary>
/// <param name="lView">The ListView to set.</param>
/// <param name="value">The new SortOrder value.</param>
/// <param name="onDesignMode">Indicates if design mode is currently active.</param>
private static void SetSortOrderProperty(ListView lView, SortOrder value, bool onDesignMode)
{
if (CheckForProperty(lView, newPropertiesEnum.SortOrderProperty))
{
if (value != SortOrder.None)
{
newProperties[lView][newPropertiesEnum.SortOrderProperty] = value;
GetCustomListItemComparer(lView).SortOrder = value;
if (!onDesignMode)
lView.Sort();
}
}
}
示例10: Sort
public static void Sort(ListView lv, int iColumn)
{
ListViewUtil lvu = new ListViewUtil();
lvu.ActiveColumn = iColumn;
lv.ListViewItemSorter = lvu;
lv.Sort();
lv.ListViewItemSorter = null;
lvu = null;
}
示例11: ColumnClickTest
public void ColumnClickTest ()
{
Form myform = new Form ();
myform.ShowInTaskbar = false;
ListView mylistview = new ListView ();
mylistview.LabelEdit = true ;
mylistview.ColumnClick += new ColumnClickEventHandler (ColumnClickEventHandler);
mylistview.View = View.Details;
mylistview.SetBounds (10, 10, 200, 200, BoundsSpecified.All);
mylistview.Columns.Add ("A", -2, HorizontalAlignment.Center);
mylistview.Columns.Add ("B", -2, HorizontalAlignment.Center);
ListViewItem item1 = new ListViewItem ("A", -1);
mylistview.Items.Add (item1);
myform.Controls.Add (mylistview);
myform.ShowDialog ();
mylistview.Sort ();
Assert.AreEqual (true, eventhandled, "#A3");
myform.Dispose ();
}
示例12: SetSortKeyProperty
/// <summary>
/// Sets static property for SortKey property.
/// </summary>
/// <param name="lView">The ListView to set.</param>
/// <param name="value">The new SortKey value.</param>
/// <param name="onDesignMode">Indicates if design mode is currently active.</param>
private static void SetSortKeyProperty(ListView lView, int value, bool onDesignMode)
{
if (CheckForProperty(lView, newPropertiesEnum.SortKeyProperty))
{
if ((lView.Columns.Count > 0) && ((value < 0) || (value >= lView.Columns.Count)))
throw new InvalidOperationException("Invalid property value");
newProperties[lView][newPropertiesEnum.SortKeyProperty] = value;
GetCustomListItemComparer(lView).SortKey = value;
if (!onDesignMode)
lView.Sort();
}
}
示例13: VirtualMode_Exceptions
public void VirtualMode_Exceptions()
{
ListView lvw = new ListView ();
lvw.Items.Add ("Simple item");
try {
lvw.VirtualMode = true;
Assert.Fail ("#A1");
} catch (InvalidOperationException) {
}
lvw.Items.Clear();
lvw.VirtualMode = true;
lvw.VirtualListSize = 1;
lvw.RetrieveVirtualItem += ListViewRetrieveVirtualItemHandler;
CreateListViewItems (1);
try {
lvw.Sort ();
Assert.Fail ("#A3");
} catch (InvalidOperationException) {
}
}
示例14: SortListView
private void SortListView(ListView lv)
{
if (lv.Sorting == SortOrder.Ascending)
lv.Sorting = SortOrder.Descending;
else
lv.Sorting = SortOrder.Ascending;
lv.Sort();
}
示例15: Sort
public static void Sort(ref ListView lv, ref ListViewColumnSorter lvwColumnSorter, ColumnClickEventArgs e)
{
try
{
if (lvwColumnSorter.SortColumn == e.Column)
{
if (lvwColumnSorter.Order == SortOrder.Ascending)
{
lvwColumnSorter.Order = SortOrder.Descending;
}
else
{
lvwColumnSorter.Order = SortOrder.Ascending;
}
}
else
{
lvwColumnSorter.SortColumn = e.Column;
lvwColumnSorter.Order = SortOrder.Ascending;
}
lv.Sort();
}
catch (System.Exception e1)
{
GlobalFunction.MsgBoxException(e1.Message, "ListViewCtrl.Sort");
}
}