我有一个字符串,其中包含我从数据库中读取的以下多行字符串值:
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:00How 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.
更多推荐
发布评论