【发布时间】:2014-01-19 21:48:51
【问题描述】:
我正在尝试将带有空格的strings 写入列表框,并保持它们对齐。
代码如下:
List<String> treeNames = new List<String>();
int counter = 1;
treeNames.Add("Input ");
treeNames.Add("Output ");
treeNames.Add("Sequence Type ");
foreach (String currentData in treeNames)
{
listBox1.Items.Add(currentData + " - " + counter.ToString());
counter+=1;
}
这是我希望实现的目标:
Input - 1
Output - 2
Sequence Type - 3
相反,我得到:
Input - 1
Output - 2
Sequence Type - 3
有什么想法可以让它们对齐吗?
【问题讨论】:
-
这是 WPF 吗?还是 WinForms?
-
您不应该使用等距字体吗?
-
这个 [thread][1] 可能有助于解决您的问题 [1]:stackoverflow.com/questions/4982807/…
-
看看可能使用 ListView。
标签: c# string text listbox alignment