如何自动选择列表视图中的最小数字? [英] How can I select the lowest number in listview automatically?

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

问题描述

我想自动选择列表视图中的最小数字。我试图比较它,但它不起作用

'Dim ct As Integer 
'for ct = 0 To .Tables(0).Rows.Count - 1
'Dim ls As New ListViewItem
'ls.Text = .Tables(0).Rows(ct).Item(0)
'if ls.SubItems.Add(.Tables (0).Rows(ct).Item(2))< = ls.SubItems.Add(.Tables(0).Rows(ct).Item(2))然后这段代码不起作用它总是说这是无效的
'ls.BackColor = Color.Yellow
'lvpoapproveitem.Items.Add(ls)

解决方案

它取决于 ListView 中的值。

我会认为你的 ListView 包含整数值。

见下面的代码示例:

 ListView1.MultiSelect =  False  
ListView1.Items( 0 )。Selected = True
Dim _mItemMinValue As Integer = ListView1。项目( 0 )。文本
对于 每个 _mItem 作为 ListViewItem ListView1.Items
如果 _mItemMinValue> Val(_mItem.Text)然后
_mItem.Selected = True
结束 如果
下一步



此代码自动选择 ListViewItem ListView中存在最低整数值

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


I want to select automatically the lowest number in list view. I tried to compare it but it doesn't work

'Dim ct As Integer
           'For ct = 0 To .Tables(0).Rows.Count - 1
           '    Dim ls As New ListViewItem
           '    ls.Text = .Tables(0).Rows(ct).Item(0)
           '   " If ls.SubItems.Add(.Tables(0).Rows(ct).Item(2)) <= ls.SubItems.Add(.Tables(0).Rows(ct).Item(2)) Then" This code doesn't work It always says that it is invalid
           '        ls.BackColor = Color.Yellow
           '        lvpoapproveitem.Items.Add(ls)

解决方案

It depends on the values present in the ListView.
I will considered that your ListView contains Integer Values.
See below code example :

ListView1.MultiSelect = False
ListView1.Items(0).Selected = True
Dim _mItemMinValue As Integer = ListView1.Items(0).Text
For Each _mItem As ListViewItem In ListView1.Items
     If _mItemMinValue > Val(_mItem.Text) Then
               _mItem.Selected = True
     End If
 Next


This code automatically select ListViewItem with Lowest Integer value present in the ListView.
I hope this will help you. :)


这篇关于如何自动选择列表视图中的最小数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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