替换列表框中的文本 [英] Replace text in listbox

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

问题描述

你好,



我想在列表框中替换单词或carachters。



 Listbox1.Text = Listbox1.Text.Replace(  





这不起作用。

解决方案

你的语句什么都不做,因为文本 ListBox 上的属性只是(可能)选择

项:你必须仔细阅读文档 [ ^ ],以满足您的要求。

如果你需要替换所有列表框项目文本中的字符串,那么就循环它们。另一方面,如果您只需要更改所选项目的文本,则首先获取对它的引用,然后在其 Text 属性上使用replace方法。 / BLOCKQUOTE>

Hello,

I want to replace words or carachters in a listbox.

Listbox1.Text = Listbox1.Text.Replace(":", ",")



This is not working.

解决方案

You statement does nothing, because the Text property on a ListBox just (possibly) selects
an item: you have to careful read the documentation[^], in order to fulfill your requirement.
If you need to replace the string in the text of all the listbox items, then loop over them. On the other hand, if you need to change only the text of the selected item then, first obtain a reference to it and then use the replace method on its Text property.


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

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