从列表视图的选定项中填充字符串 [英] Populating a string from the selected items of a listview

查看:57
本文介绍了从列表视图的选定项中填充字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有一个列表视图,现在可以选择多个条目

。我现在需要将所选条目的值

放入一个字符串中以用于报告目的。


我使用以下语法但继续获取错误指定演员

无效。我不知道是什么导致了这个?可以有人帮忙吗?


每个项目如ListViewItem在

frmRepParams.lstAnalysis.SelectedItems

如果Len(strAnalysis)= 0然后

strAnalysis = Item.Text

Else:strAnalysis = strAnalysis& , &

frmRepParams.lstAnalysis.SelectedValue


结束如果

下一页

I have a listview in my application which now enables multiple entries
to be selected. I now need to put the value of the selected entries
into a string to be used for reporting purposes.

I use the following syntax but keep getting the error "Specified cast
is not valid". I don''t know what''s causing this ? Can anybody help ?

For Each Item As ListViewItem In
frmRepParams.lstAnalysis.SelectedItems
If Len(strAnalysis) = 0 Then
strAnalysis = Item.Text
Else : strAnalysis = strAnalysis & ", " &
frmRepParams.lstAnalysis.SelectedValue

End If
Next

推荐答案

其他部分应该是这样吗?


strAnalysis = strAnalysis& , &安培; Item.Text


" Robert Zirpolo" < RO ****** @ hotmail.com>在消息中写道

新闻:2d ************************** @ posting.google.c om ...

我的应用程序中有一个列表视图,现在可以选择多个条目

。我现在需要将所选条目的值

放入一个字符串中以用于报告目的。


我使用以下语法但继续获取错误指定演员

无效。我不知道是什么导致了这个?可以有人帮忙吗?


每个项目如ListViewItem在

frmRepParams.lstAnalysis.SelectedItems

如果Len(strAnalysis)= 0然后

strAnalysis = Item.Text

Else:strAnalysis = strAnalysis& , &

frmRepParams.lstAnalysis.SelectedValue


结束如果

下一页
Should the Else part be like this?

strAnalysis = strAnalysis & ", " & Item.Text

"Robert Zirpolo" <ro******@hotmail.com> wrote in message
news:2d**************************@posting.google.c om...
I have a listview in my application which now enables multiple entries
to be selected. I now need to put the value of the selected entries
into a string to be used for reporting purposes.

I use the following syntax but keep getting the error "Specified cast
is not valid". I don''t know what''s causing this ? Can anybody help ?

For Each Item As ListViewItem In
frmRepParams.lstAnalysis.SelectedItems
If Len(strAnalysis) = 0 Then
strAnalysis = Item.Text
Else : strAnalysis = strAnalysis & ", " &
frmRepParams.lstAnalysis.SelectedValue

End If
Next


在其他部分,您可以这样做:

strAnalysis = strAnalysis& , &安培; Item.Text


顺便说一句,如果lstAnalysis是listview控件,则SelectedValue不应该工作

因为它不是listview控件的成员而是一个成员从中导出ListBox和ComboBox的
ListControl。


希望这会有所帮助..

Imran。


" Robert Zirpolo" < RO ****** @ hotmail.com>在消息中写道

新闻:2d ************************** @ posting.google.c om ...
In the Else part, you could just do:
strAnalysis = strAnalysis & ", " & Item.Text

Btw, if lstAnalysis is a listview control, SelectedValue shouldn''t work
since its not a member of the listview control but a member of the
ListControl from which the ListBox and ComboBox are derived.

hope this helps..
Imran.

"Robert Zirpolo" <ro******@hotmail.com> wrote in message
news:2d**************************@posting.google.c om...
我的应用程序中有一个列表视图,现在可以选择多个条目。我现在需要将所选条目的值
放入一个字符串中以用于报告目的。

我使用以下语法但仍然收到错误指定的强制转换无效。我不知道是什么导致了这个?可以有人帮忙吗?

每个项目如ListViewItem在
frmRepParams.lstAnalysis.SelectedItems
如果Len(strAnalysis)= 0那么
strAnalysis = Item.Text
Else:strAnalysis = strAnalysis& , &
frmRepParams.lstAnalysis.SelectedValue

结束如果
下一步
I have a listview in my application which now enables multiple entries
to be selected. I now need to put the value of the selected entries
into a string to be used for reporting purposes.

I use the following syntax but keep getting the error "Specified cast
is not valid". I don''t know what''s causing this ? Can anybody help ?

For Each Item As ListViewItem In
frmRepParams.lstAnalysis.SelectedItems
If Len(strAnalysis) = 0 Then
strAnalysis = Item.Text
Else : strAnalysis = strAnalysis & ", " &
frmRepParams.lstAnalysis.SelectedValue

End If
Next



道歉,你的权利。


但这不是问题,它在尝试填充字符串
时失败了。代码仍然带有指定的演员无效

错误。

***通过Developersdex发送 http://www.developersdex.com ***

不要只是参加USENET ......获得奖励为它!
Apologies, your right.

But this is not the issue, it fails at the point it attempts to populate
the string. The code still sails with an "Specified cast not valid"
error.
*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!


这篇关于从列表视图的选定项中填充字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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