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


C# ListView.FindItemWithText方法代码示例

本文整理汇总了C#中System.Windows.Forms.ListView.FindItemWithText方法的典型用法代码示例。如果您正苦于以下问题:C# ListView.FindItemWithText方法的具体用法?C# ListView.FindItemWithText怎么用?C# ListView.FindItemWithText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.ListView的用法示例。


在下文中一共展示了ListView.FindItemWithText方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddItemToListView

        private Boolean AddItemToListView(ListView listView, String path)
        {
            if (null != listView.FindItemWithText(path))
            {
                return false;
            }

            ListViewItem lvi = new ListViewItem((listView.Items.Count + 1).ToString());

            lvi.SubItems.Add(""); // 완료 여부 컬럼 - 처음에는 빈칸을 넣는다.
            lvi.SubItems.Add(path); //파일 경로

            // 기본적으로 파일 생성날짜를 읽어온다.
            // Exif가 존재한다면 아래 로직에서 Exif에서 생성된 날짜를 읽어온다.
            FileInfo fileInfo = new FileInfo(path);
            String fileCreationTime = fileInfo.LastWriteTime.Date.ToString("yyyy-MM-dd").Substring(0, 10);

            // Exif 지원 확장자인 경우 Exif에서 생성된 날짜를 읽어온다.
            if (true == IsExifSupportExtension(path))
            {
                 String exifDate = GetExifDate(path);

                if (false == String.IsNullOrEmpty(exifDate))
                {
                    exifDate = exifDate.Substring(0, 10);
                    fileCreationTime = exifDate;
                }
            }

            lvi.SubItems.Add(fileCreationTime); // 생성 날짜

            long fileSize = fileInfo.Length;
            // 파일 크기
            if (0 == fileSize)
                lvi.SubItems.Add("0 KB");
            else if (1024 > fileSize)
                lvi.SubItems.Add("1 KB");
            else if (1048576 > fileSize)
                lvi.SubItems.Add(String.Format("{0:N}", (double)(fileSize / 1024)) + " KB");
            else if (1073741824 > fileSize)
                lvi.SubItems.Add(String.Format("{0:N}", (double)(fileSize / 1048576)) + " MB");
            else
                lvi.SubItems.Add(String.Format("{0:N}", (double)(fileSize / 1073741824)) + " GB");

            listView.Items.Add(lvi);
            return true;
        }
开发者ID:tinymin,项目名称:Groupic,代码行数:47,代码来源:FormMain.cs

示例2: FindItemWithText_Exceptions

		public void FindItemWithText_Exceptions ()
		{
			ListView lvw = new ListView ();

			// Shouldn't throw any exception
			lvw.FindItemWithText (null);

			try {
				lvw.FindItemWithText (null, false, 0);
				Assert.Fail ("#A1");
			} catch (ArgumentOutOfRangeException) {
			}

			try {
				lvw.FindItemWithText (null, false, lvw.Items.Count);
				Assert.Fail ("#A2");
			} catch (ArgumentOutOfRangeException) {
			}

			// Add a single item
			lvw.Items.Add ("bracket");

			try {
				lvw.FindItemWithText (null);
				Assert.Fail ("#A3");
			} catch (ArgumentNullException) {
			}

			try {
				lvw.FindItemWithText ("bracket", false, -1);
				Assert.Fail ("#A4");
			} catch (ArgumentOutOfRangeException) {
			}

			try {
				lvw.FindItemWithText ("bracket", false, lvw.Items.Count);
				Assert.Fail ("#A5");
			} catch (ArgumentOutOfRangeException) {
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:40,代码来源:ListViewTest.cs

示例3: FindItemWithText

		public void FindItemWithText ()
		{
			ListView lvw = new ListView();
			ListViewItem lvi1 = new ListViewItem (String.Empty);
			ListViewItem lvi2 = new ListViewItem ("angle bracket");
			ListViewItem lvi3 = new ListViewItem ("bracket holder");
			ListViewItem lvi4 = new ListViewItem ("bracket");
			lvw.Items.AddRange (new ListViewItem [] { lvi1, lvi2, lvi3, lvi4 });

			Assert.AreEqual (lvi1, lvw.FindItemWithText (String.Empty), "#A1");
			Assert.AreEqual (lvi3, lvw.FindItemWithText ("bracket"), "#A2");
			Assert.AreEqual (lvi3, lvw.FindItemWithText ("BrackeT"), "#A3");
			Assert.IsNull (lvw.FindItemWithText ("holder"), "#A5");

			Assert.AreEqual (lvw.Items [3], lvw.FindItemWithText ("bracket", true, 3), "#B1");

			Assert.AreEqual (lvw.Items [2], lvw.FindItemWithText ("bracket", true, 0, true), "#C1");
			Assert.AreEqual (lvw.Items [3], lvw.FindItemWithText ("bracket", true, 0, false), "#C2");
			Assert.AreEqual(lvw.Items [3], lvw.FindItemWithText("BrackeT", true, 0, false), "#C3");
			Assert.IsNull (lvw.FindItemWithText ("brack", true, 0, false), "#C4");

			// Sub item search tests
			lvw.Items.Clear ();

			lvi1.Text = "A";
			lvi1.SubItems.Add ("car bracket");
			lvi1.SubItems.Add ("C");

			lvi2.Text = "B";
			lvi2.SubItems.Add ("car");

			lvi3.Text = "C";

			lvw.Items.AddRange (new ListViewItem [] { lvi1, lvi2, lvi3 });

			Assert.AreEqual (lvi1, lvw.FindItemWithText ("car", true, 0), "#D1");
			Assert.AreEqual (lvi3, lvw.FindItemWithText ("C", true, 0), "#D2");
			Assert.AreEqual (lvi2, lvw.FindItemWithText ("car", true, 1), "#D3");
			Assert.IsNull (lvw.FindItemWithText ("car", false, 0), "#D4");

			Assert.AreEqual (lvi1, lvw.FindItemWithText ("car", true, 0, true), "#E1");
			Assert.AreEqual (lvi2, lvw.FindItemWithText ("car", true, 0, false), "#E2");
			Assert.AreEqual (lvi2, lvw.FindItemWithText ("CaR", true, 0, false), "#E3");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:44,代码来源:ListViewTest.cs

示例4: medicationOrSupplementExistInTheList

 private bool medicationOrSupplementExistInTheList(ListView listView, String value)
 {
     return listView.FindItemWithText(value) != null;
 }
开发者ID:garciad7,项目名称:health-records-project,代码行数:4,代码来源:Form2.cs

示例5: searchList

 /// <summary>
 /// General function to search any list view form. Highlights rows with matches.
 /// </summary>
 /// <param name="needle">String to search for</param>
 /// <param name="haystack">ListView object to search in</param>
 private void searchList(string needle, ListView haystack)
 {
     if (haystack.Items.Count > 0)
     {
         // Focus the list view
         haystack.Focus();
         // Clear currently selected items
         haystack.SelectedItems.Clear();
         int i = 0;
         ListViewItem found;
         do
         {
             // Recursively find all instances of the given text, starting from zero
             found = haystack.FindItemWithText(needle, true, i, true);
             if (found != null)
             {
                 // Select found item
                 found.Selected = true;
                 // Next search starts from the next element in the list view
                 i = found.Index + 1;
             }
             else
             {
                 // Otherwise, stop
                 i = haystack.Items.Count;
             }
         } while (i < haystack.Items.Count);
     }
     // If nothing found, show message
     if (haystack.SelectedItems.Count == 0)
     {
         MessageBox.Show("Value could not be found.", "Search", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
开发者ID:CJxD,项目名称:CoreView,代码行数:39,代码来源:MainWindowSearching.cs

示例6: hasNSTP

        public bool hasNSTP(ListView lv)
        {
            bool isTrue = false;
            if (lv.FindItemWithText("CWTS/ROTC").Index > 0)
            {
                isTrue = true;
                hasNSTPPick = true;
            }

            return isTrue;
        }
开发者ID:flashprogram,项目名称:SSCCashierMagSys,代码行数:11,代码来源:StudentAccount.cs

示例7: Buscar_ListView

 //funciones
 public static void Buscar_ListView(ListView LV, string sValor, Boolean bSubItems)
 {
     ListViewItem foundItem = new ListViewItem();
     foundItem = LV.FindItemWithText(sValor, bSubItems, 0, true);
     if (foundItem != null)
     {
         LV.HideSelection = false;
         LV.Items[foundItem.Index].Selected = true;
         LV.Items[foundItem.Index].EnsureVisible();
     }
 }
开发者ID:eldister,项目名称:sisctd,代码行数:12,代码来源:Helper.cs

示例8: ScanFirmwareDirectory

        private void ScanFirmwareDirectory()
        {
            // Apparently stop and start is a typical way of resetting the timer
            // We want to reset the timer here
            ScanTimer.Stop();

            // hexlist_buffer is not used in main thread
            hexList_buffer = new ListView();

            list_sorting(false); // disable sorting while we re-populate

            ProcessDirectory("\\\\wpgfile01\\EDC\\Firmware\\Price"); // fill the list

            // Move the data from buffer to the actual hex list
            // Since we might be in a different thread, this will need to use the invoke call
            list_clear();

            // No filter
            if (string.IsNullOrWhiteSpace(FilterBox.Text))
            {
                foreach (ListViewItem item in hexList_buffer.Items)
                {
                    // Transfer from buffer to the real displayed hexlist
                    list_add((ListViewItem)item.Clone());
                    //ShowTimerEventFired((ListViewItem)item.Clone());
                }
            }
            else
            {
                // Find all keywords
                string[] key_words = FilterBox.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                // Trim off all spaces, just in case
                for (var i = 0; i < key_words.Length; i++)
                    key_words[i] = key_words[i].Trim();

                // Get all matches
                ListViewItem item_buffer = new ListViewItem();
                foreach (string key_word in key_words)
                {
                    var i = 0;
                    while ((item_buffer = hexList_buffer.FindItemWithText(key_word, false, i)) != null && !string.IsNullOrEmpty(key_word))
                    {
                        // Implent the Start Index for the finder
                        i = item_buffer.Index + 1;

                        //Put the finding into the list
                        list_add((ListViewItem)item_buffer.Clone());
                        //ShowTimerEventFired((ListViewItem)item_buffer.Clone());
                    }
                }
            }

            // Resume the sorting, since we finished building the list
            list_sorting(true);

            // We want to reset the timer here
            ScanTimer.Start();
        }
开发者ID:PriceElectronics,项目名称:FWDirectoryScanner,代码行数:59,代码来源:MainForm.cs


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