gpt4 book ai didi

c# - 列表框项目中的多行 C#

转载 作者:太空宇宙 更新时间:2023-11-03 15:06:57 25 4
gpt4 key购买 nike

我正在尝试将带有换行符的数据放入列表框中的一项

如何在此命令中创建分界线?

listBox1.Items.Add("");

或其他命令

example to what I mean

谢谢

最佳答案

public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();

var product = new Product
{
ProductName = "Some name",
Id = "123X",
Size = "Big",
OutOfStock = "true"
};

var itm = new ListBoxItem {Content = $"Product Name: {product.ProductName} {Environment.NewLine}" +
$"ID: {product.Id} {Environment.NewLine}" +
$"Size: {product.Size} {Environment.NewLine}" +
$"Out of stock {product.OutOfStock}"
};

listBox.Items.Add(itm);
}
}

public class Product
{
public string ProductName { get; set; }
public string Id { get; set; }
public string Size { get; set; }
public string OutOfStock { get; set; }
}

关于c# - 列表框项目中的多行 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42975873/

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