当前位置: 首页>>代码示例>>C#>>正文


C# ListView.Sort方法代码示例

本文整理汇总了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();
        }
开发者ID:andreigec,项目名称:ANDREICSLIB,代码行数:34,代码来源:ListViewSorter.cs

示例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();
	}
开发者ID:Helmut-Ortmann,项目名称:Enterprise-Architect-Toolpack,代码行数:26,代码来源:ListViewColumnSorter.cs

示例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]);
 }
开发者ID:falerin,项目名称:Sims4Tools,代码行数:8,代码来源:ManageWrappersDialog.cs

示例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;
        }
开发者ID:kjrcda,项目名称:FinanceTracker,代码行数:17,代码来源:ListSorter.cs

示例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();
		}		
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:21,代码来源:AttachToProcessForm.cs

示例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();
        }
开发者ID:jiangzhonghui,项目名称:Process-Watch,代码行数:22,代码来源:Utility.cs

示例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();
        }
开发者ID:itayB,项目名称:FinancePlus,代码行数:22,代码来源:GUIHandler.cs

示例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();
        }
开发者ID:abezzubets,项目名称:DDTGenerator,代码行数:18,代码来源:ListViewColumnSorter.cs

示例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();
                }
            }
        }
开发者ID:WebMAPTestUser,项目名称:SKS,代码行数:20,代码来源:ListViewHelper.cs

示例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;
 }
开发者ID:CodeCowboyOrg,项目名称:TaskRunner,代码行数:9,代码来源:ListViewUtil.cs

示例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 ();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:20,代码来源:ListViewEventTest.cs

示例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();
            }
        }
开发者ID:WebMAPTestUser,项目名称:SKS,代码行数:19,代码来源:ListViewHelper.cs

示例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) {
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:24,代码来源:ListViewTest.cs

示例14: SortListView

 private void SortListView(ListView lv)
 {
     if (lv.Sorting == SortOrder.Ascending)
         lv.Sorting = SortOrder.Descending;
     else
         lv.Sorting = SortOrder.Ascending;
     lv.Sort();
 }
开发者ID:JamesTryand,项目名称:NetSqlAzMan,代码行数:8,代码来源:frmStoreGroupsProperties.cs

示例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");
            }
        }
开发者ID:ideayapai,项目名称:docviewer,代码行数:28,代码来源:ListViewCtrl.cs


注:本文中的System.Windows.Forms.ListView.Sort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。