如何从列表框中选择所有值 [英] how to select all the value from list box

查看:72
本文介绍了如何从列表框中选择所有值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请在这里检查我的下面的代码我想从列表框中选择进程名称逐个杀死进程,但我需要从列表框中关闭所有任务,而不选择任何一个只想杀死所有进程点击按钮..所以请你帮助我



提前预付

<前lang =vb> Dim p As System.Diagnostics.Process

对于 每个 p System.Diagnostics.Process.GetProcesses()

Dim arr() As String = _
lstProcesses.SelectedItem.ToString()。Split( -

Dim sProcess As String = arr( 0 )。修剪()
Dim iId 正如 整数 = Convert.ToInt32(arr( 1 )。Trim())

如果 p.ProcessName = sProcess p.Id = iId 然后
p.Kill()
结束 如果

下一步

解决方案

如果您打算浏览所有列表框的所选项目(这是我的猜测),那么,这里是:

 对于 每个 li 作为 ListItem  lstProcesses.Items 
如果 li.Selected = True 然后

' 在此处插入代码以终止进程

结束 如果
下一步





干杯,

Edo


将您的上述代码写入另一个 For Loop 如果要关闭所有进程存在在列表框中,无论用户选择如何。

 对于 每个 _mLiestItem  ListBox1.Items 
' 您的代码就在这里。
下一步



我希望它会对你有所帮助。 :)


please check my below code here i want to kill process one by one on selecting the process name from list box, but i need to close all the task from my list box,without select any one just want to kill all the process on button click..so plz can u help me

Thanx in advance

Dim p As System.Diagnostics.Process
 
For Each p In System.Diagnostics.Process.GetProcesses()
 
Dim arr() As String = _
lstProcesses.SelectedItem.ToString().Split("-")
 
Dim sProcess As String = arr(0).Trim()
Dim iId As Integer = Convert.ToInt32(arr(1).Trim())
 
If p.ProcessName = sProcess And p.Id = iId Then
p.Kill()
End If
 
Next

解决方案

If what you intended is to run through all the listbox's selected items, (that's my guess) then, here goes:

For Each li As ListItem In lstProcesses.Items
   If li.Selected = True Then
     
     ' Here you insert the code to kill the process           

   End If
Next



Cheers,
Edo


Write your above code in another For Loop If you want to close all Process present in List Box irrespective of user selection.

For Each _mLiestItem In ListBox1.Items
       'Your Code Goes Here.
Next


I hope it will help you. :)


这篇关于如何从列表框中选择所有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆