可单击列表框打开文本文档VB.NET
这是我的密码可单击列表框打开文本文档VB.NET,vb.net,listbox,Vb.net,Listbox,这是我的密码 Dim InputStr As String = CrystalClearTextBox1.Text For Each FileStr As String In IO.Directory.GetFiles("C:\Users\root\Desktop\databases", "*.txt") If IO.File.ReadAllText(FileStr).IndexOf(InputStr) >= 0 Then ListBo
Dim InputStr As String = CrystalClearTextBox1.Text
For Each FileStr As String In IO.Directory.GetFiles("C:\Users\root\Desktop\databases", "*.txt")
If IO.File.ReadAllText(FileStr).IndexOf(InputStr) >= 0 Then
ListBox1.Items.Add(IO.Path.GetFileName(FileStr))
Else
ListBox1.Items.Add("No Results found!")
End If
Next
End Sub
也可以添加.csv、.sql而不是.txt吗
我试图做的是当它返回它所在的文本文件时,能够单击它并打开文本文件并滚动到文本文件中的单词位置,这可能吗?如果你愿意帮助我,我会非常感激的 你有两个问题。我将给出第一个,然后为那一个做一个不同的主题
Dim files = New DirectoryInfo("your directory").GetFiles()
'set the data source
lsb.DataSource = files
'this will be the display in the listbox
lsb.DisplayMember = "Name"
'this is the full path for opening the file
lsb.ValueMember = "FullName"
用法-在列表框中选择DexChanged事件
'this will open whatever program is need to open the document
Process.Start(lsv.SelectedValue.ToString)
不必担心sql和csv,只需要知道如何单击列表框文件。是否希望列表框中的文件名不带扩展名,但能够打开不同的文件类型?好的,我用不同的方法完成了,但现在我想做的是,当它打开文本文件时,我希望它自动执行记事本中的“查找”功能,这可能吗?这是问题2,打开一个新话题。如果我的答案对马克有帮助的话。我不会同意的,我已经达到极限了。你上次问问题已经0天了。我们要求您在再次询问之前等待6天。据我所知,在打开进程时无法使用查找功能。