System.Windows.Forms.ListView.FindItemWithText C# (CSharp) Method

FindItemWithText() public method

public FindItemWithText ( string text ) : System.Windows.Forms.ListViewItem
text string
return System.Windows.Forms.ListViewItem
		public ListViewItem FindItemWithText (string text)
		{
			if (items.Count == 0)
				return null;

			return FindItemWithText (text, true, 0, true);
		}

Same methods

ListView::FindItemWithText ( string text, bool includeSubItemsInSearch, int startIndex ) : System.Windows.Forms.ListViewItem
ListView::FindItemWithText ( string text, bool includeSubItemsInSearch, int startIndex, bool isPrefixSearch ) : System.Windows.Forms.ListViewItem
ListView::FindItemWithText ( string text, bool includeSubItemsInSearch, int startIndex, bool isPrefixSearch, bool roundtrip ) : System.Windows.Forms.ListViewItem

Usage Example

Example #1
0
        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;
        }
All Usage Examples Of System.Windows.Forms.ListView::FindItemWithText
ListView