(Delphi)如何读取字符串变量并将其拆分为多行并放入列表框中((Delphi) How to read a string variable and split it into multiple l

编程入门 行业动态 更新时间:2024-10-20 09:22:01
(Delphi)如何读取字符串变量并将其拆分为多行并放入列表框中((Delphi) How to read a string variable and split it into multiple lines and put into a listbox)

我有一个字符串,其中包含我从数据库中读取的以下多行字符串值:

01/01/2000, 8:00 02/07/2001, 8:00 09/12/2002, 23:00

如何将这些行中的每一行放入其自己的行列表框中。

I have a string containing the following multi-line string value that I read from my database:

01/01/2000, 8:00 02/07/2001, 8:00 09/12/2002, 23:00

How can I put each of those lines into a listbox on its own line.

最满意答案

如果您手头有一个列表框,并且数据库为您提供了一个嵌入了换行符的字符串,那么您可以简单地执行此操作。

ListBox.Items.Text := QueryString;

当您分配Items的Text属性时,将通过拆分换行符来解析字符串。 每行都作为单独的项添加到列表框中。

如果您的字符串使用不同的分隔符,则可以使用DelimitedText和Delimiter 。

If you have a list box at hand, and the database hands you a string with line breaks embedded, then you can simply do this.

ListBox.Items.Text := QueryString;

When you assign to the Text property of Items, the string will be parsed by splitting on line breaks. Each line is added to the list box as a separate item.

If your string is using a different delimiter, then you can use DelimitedText and Delimiter instead.

更多推荐

本文发布于:2023-08-01 14:13:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1359168.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   变量   框中   放入   列表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!