Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 列表框对齐文本_C#_Listbox_Alignment - Fatal编程技术网

C# 列表框对齐文本

C# 列表框对齐文本,c#,listbox,alignment,C#,Listbox,Alignment,我有一个列表框,包含两个元素:项目和价格 我这样加上: lbtest.Items.Add(new ListBoxItem() { Content = item + prijs, FontSize = 14, Foreground = Brushes.Red }); 当然,这会导致: -------------------- Fries€2,00 // btw they are from Belgium NOT from France lol Ketchup€0,

我有一个
列表框
,包含两个元素:
项目和价格

我这样加上:

lbtest.Items.Add(new ListBoxItem()
{
    Content = item + prijs,
    FontSize = 14,
    Foreground = Brushes.Red
});
当然,这会导致:

--------------------
Fries€2,00 // btw they are from Belgium NOT from France lol
    Ketchup€0,30
Burger€2,00
    Onion€0,10
SomeFood€2,00
    SomeSubItem€500
--------------------
我玩过
.padlift
.padrright
但这些都没有给我想要的条件:

--------------------
Fries              €2,00
    Ketchup        €0,30
Burger             €2,00
    Onion          €0,10
SomeFood           €2,00
    SomeSubItem    €500
--------------------
有什么计算方法可以实现这一点吗


我的
列表框
有一个静态宽度,也许我可以用它做些什么?

您应该尝试使用:

    var name = "ItemName";
    var price = "€2,00";

    var daa = String.Format("{0, 5} {1, 10}", name, price);
结果是:“ItemName 2,00欧元”

"ItemName €2,00" {0,1,2..[align]}非常好