插入列表框中字符之间的空白 [英] Insert whitespace between characters in listbox

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

问题描述

我想插入我的asp.net C#应用程序项目到一个列表框

我串联一些值,并把空格在它们之间的,但它不存在于列表框显示。

 列表项LT =新的ListItem();
        lt.Text = ITEMNAME ++酒吧code ++价格; //问题
        lt.Value =酒吧code;
        lstMailItems.Items.Add(LT);

我甚至试图

  lt.Text = ITEMNAME +\\ t \\ t+酒吧code +\\ t \\ t+价格; //问题
lt.Text = ITEMNAME +&放大器; NBSP; +酒吧code +&放大器; NBSP; +价格; //&安培; NBSP显示为文本

不过,即使似乎并没有工作。我怎样才能把这些字符串之间的空白,使其在列表框中显示出来,以及


解决方案

 字符串中的空格=&放大器; NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP;; //没有与放大器后位;
        空格= Server.HtmlDe code(空格);        lt.Text = ITEMNAME +空格+酒吧code +空格+价格; //作品

I am trying to insert items into a listbox in my asp.net C# application

I concatenate some values and put whitespace in between them but it doesn't show up in the listbox.

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

i even tried

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

but that even doesn't seem to work. How can I put whitespace between these strings so that it shows up in the listbox as well

解决方案

        string spaces = "& nbsp;& nbsp;& nbsp;& nbsp;"; // without spaces after &
        spaces = Server.HtmlDecode(spaces);

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

这篇关于插入列表框中字符之间的空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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