gpt4 book ai didi

c# - 在列表框中的字符之间插入空格

转载 作者:太空狗 更新时间:2023-10-30 00:36:40 26 4
gpt4 key购买 nike

我正在尝试将项目插入到我的 asp.net C# 应用程序中的列表框中

我连接了一些值并在它们之间放置了空格,但它没有显示在列表框中。

        ListItem lt = new ListItem();
lt.Text = ItemName + " " + barcode + " " + price; // problem
lt.Value = barcode;
lstMailItems.Items.Add(lt);

我试过了

lt.Text = ItemName + "\t\t" + barcode + "\t\t" + price; // problem
lt.Text = ItemName + "& nbsp;" + barcode + "& nbsp;" + price; // &nbsp shows up as text

但这似乎也行不通。我怎样才能在这些字符串之间放置空格,以便它也显示在列表框中

最佳答案

string spaces = Server.HtmlDecode("    "); 

lt.Text = ItemName + spaces + barcode + spaces + price; // works

关于c# - 在列表框中的字符之间插入空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1237425/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com