问题描述
需要帮助,首先不是英文好,
我有listview显示来自指定目录的文本文件中的项目(文件夹),我想搜索框和(TextBox1)和cmdButton(Button1)来搜索和显示我在第三列搜索的所有项目或ID号。
EX:
第1栏:日期和时间:
第2栏:姓名:
第3栏:身份证号码:
08-08-2017 06:06:00,John Lucas,1010000
08-08-2017 07:00:00, April Dun,1010023
08-08-2017 08:45:00,Kevin Elmo,1010014
08-08-2017 09:06:00,John Lucas,1010000
08-08-2017 10:24:00,Ed Olivia,1010012
08-08-2017 11:47:00,John Lucas,1010000
08-08-2017 12:56:00,Liza Ben,1010001
我想通过搜索ID号码显示John Lucas的数据(项目)并在listview中显示(另一个列表视图)
我尝试过:
'这是仅从文本文件显示我的项目的代码,我不知道,我要求你提供一些帮助,TIA。'
Private Sub Form1_Load(sender As Object,e As EventArgs)处理MyBase.Load,MyBase.DockChanged
lvDETAILS.View = View.Details
lvDETAILS.Columns .Add(Date / Time:,220,HorizontalAlignment.Left)
lvDETAILS.Columns.Add(Employee Name:,280,HorizontalAlignment.Left)
lvDETAILS.Columns.Add(ID编号:,120,HorizontalAlignment.Left)
lvDETAILS.Columns.Add(Department:,250,HorizontalAlignment.Left)
lvDETAILS.Columns.Add(User Type:,200,HorizontalAlignment .Left)
lvDETAILS.Columns.Add(ESD检查结果:,200,HorizontalAlignment.Left)
Dim File_Name As String =D:\esdcheck \DET.dll
Dim objReader As New IO.StreamReader(File_Name)
Dim newarray(6)As String
Dim DateTime As String
Dim Name As String
Dim IDNum As String
Dim Department As String
Dim UserType As String
Dim ESDResult As String
Do而objReader.Peek<> -1
newarray = objReader.ReadLine()。Split(,)
DateTime = newarray(0)
Name = newarray(1)
IDNum = newarray(2)
Department = newarray(3)
UserType = newarray(4)
ESDResult = newarray(5)
Dim x As Integer = lvDETAILS.Items.Add(New ListViewItem(New String) (){DateTime}))。索引'Para sa Listview unang Column depende sa base sa index
lvDETAILS.Items.Item(x).SubItems.Add(Name)'yung'x'po na yun ay number of index na nakaset per column。,ilalagay sa second column depende sa index
lvDETAILS.Items.Item(x).SubItems.Add(IDNum)'sunod sunod lang po pa pag lagay depende sa dami ng column
lvDETAILS.Items.Item(x).SubItems.Add(Department)'yeah
lvDETAILS.Items.Item(x).SubItems.Add(UserType)'yeah
lvDETAILS.Items.Item(x) .SubItems.Add(ESDResult)'是的!!! eto na yung最后!
End Sub
Hi,
Need help, First not good in english,
I have listview displaying items from text file from designated directory (folder), i want search box and (TextBox1) and cmdButton (Button1) to search and display all items I search in third column or the ID Number.
EX:
Column 1: Date and Time:
Column 2: Name:
Column 3: ID Number:
08-08-2017 06:06:00, John Lucas, 1010000
08-08-2017 07:00:00, April Dun, 1010023
08-08-2017 08:45:00, Kevin Elmo, 1010014
08-08-2017 09:06:00, John Lucas, 1010000
08-08-2017 10:24:00, Ed Olivia, 1010012
08-08-2017 11:47:00, John Lucas, 1010000
08-08-2017 12:56:00, Liza Ben, 1010001
I want to display data (items) of John Lucas by searching ID Number and display it in listview (another listview)
What I have tried:
'This is the code to display my items from text file only, I don't have any idea and Im asking for some help from you, TIA.'
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load, MyBase.DockChanged lvDETAILS.View = View.Details lvDETAILS.Columns.Add("Date/Time:", 220, HorizontalAlignment.Left) lvDETAILS.Columns.Add("Employee Name:", 280, HorizontalAlignment.Left) lvDETAILS.Columns.Add("ID Number:", 120, HorizontalAlignment.Left) lvDETAILS.Columns.Add("Department:", 250, HorizontalAlignment.Left) lvDETAILS.Columns.Add("User Type:", 200, HorizontalAlignment.Left) lvDETAILS.Columns.Add("ESD Check Result:", 200, HorizontalAlignment.Left) Dim File_Name As String = "D:\esdcheck\DET.dll" Dim objReader As New IO.StreamReader(File_Name) Dim newarray(6) As String Dim DateTime As String Dim Name As String Dim IDNum As String Dim Department As String Dim UserType As String Dim ESDResult As String Do While objReader.Peek <> -1 newarray = objReader.ReadLine().Split(",") DateTime = newarray(0) Name = newarray(1) IDNum = newarray(2) Department = newarray(3) UserType = newarray(4) ESDResult = newarray(5) Dim x As Integer = lvDETAILS.Items.Add(New ListViewItem(New String() {DateTime})).Index 'Para sa Listview unang Column depende sa base sa index lvDETAILS.Items.Item(x).SubItems.Add(Name) 'yung 'x' po na yun ay number of index na nakaset per column., ilalagay sa second column depende sa index lvDETAILS.Items.Item(x).SubItems.Add(IDNum) 'sunod sunod lang po ang pag lagay depende sa dami ng column lvDETAILS.Items.Item(x).SubItems.Add(Department) 'yeah lvDETAILS.Items.Item(x).SubItems.Add(UserType) 'yeah lvDETAILS.Items.Item(x).SubItems.Add(ESDResult) 'yeah !!! eto na yung last! End Sub
这篇关于如何在listview VB.NET中搜索和显示相同的项目或重复项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!