如何在此代码中将Listbox1替换为Treeview? [英] How Can I replace Listbox1 to Treeview In This Code?
本文介绍了如何在此代码中将Listbox1替换为Treeview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前,我有这段代码可以在我的目录中搜索md5散列,但它使用listbox1.selecteditem进行补偿.我的问题是如何用Treeview控件替换列表框或如何将Treeview替换为其位置...
有什么想法吗?
Currently I have this code to search my directory for md5 hashes but it uses the listbox1.selecteditem to compair with. My problem is how to replace the listbox with a treeview control or to have the treeview act in its place...
any ideas?
Try
Using scanbox As New TextBox()
Dim read As String = My.Computer.FileSystem.ReadAllText("virusSig.txt")
ProgressBar1.Increment(1)
detected.Text = Conversions.ToString(CheckedListBox1.Items.Count)
files.Text = Conversions.ToString(ProgressBar1.Value)
scanbox.Text = read.ToString
Using md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider()
Dim f As FileStream = New FileStream(ListBox1.SelectedItem, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
f = New FileStream(ListBox1.SelectedItem, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
md5.ComputeHash(f)
Dim hash As Byte() = md5.Hash
Dim buff As StringBuilder = New StringBuilder()
Dim hashByte As Byte
For Each hashByte In hash
buff.Append(String.Format("{0:X2}", hashByte))
Next
If scanbox.Text.Contains(buff.ToString) Then
CheckedListBox1.Items.Add(ListBox1.SelectedItem)
End If
End Using
End Using
Catch ex As Exception
End Try
先感谢您!! :)
thank you in advance!! :)
推荐答案
用列表框和必要的绑定相关代码替换treeview后,可以使用myTreeView.SelectedNode
代替ListBox1.SelectedItem
(您可能还需要确保调用的方法的数据类型已更改.)
After replacing treeview with listbox and necessary binding related code, you can usemyTreeView.SelectedNode
in place ofListBox1.SelectedItem
(You might also need to make sure Datatype to the methods called are changed.)
这篇关于如何在此代码中将Listbox1替换为Treeview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文