gpt4 book ai didi

c# - 如何在 C# 中将选中的复选框显示到消息框中

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

我想知道如何像下图那样做:

enter image description here

在“摘要”(右侧)的“您购买的:”下,我想列出用户在“可用图书”(左侧)中 checkin 的选项

private void btnPurchase_Click(object sender, EventArgs e)
{
string BOOKS;
MessageBox.Show("You Purchase :\n"
+"\t" + BOOKS + "\n" //checked checkbox shows here
+ "The selected payment method is : " + payment
+ "\nYour comment about us : " + txtKomen.Text);
}

我使用上面的代码,它只显示第一个选中的复选框,如何在消息框中添加另一个选中的复选框?

我应该为 BOOKS 使用数组吗?如果是这样,如何将它循环到消息框中?

最佳答案

你可以这样做:

private void btnPurchase_Click(object sender, EventArgs e)
{
string[] BOOKS;
var sb = new StringBuilder();
foreach(var item in BOOKS)
{
sb.Append($"\t{item}");
sb.AppendNewLine();
}
MessageBox.Show("You Purchase :\n"
+ sb.ToString()//checked checkbox shows here
+ "The selected payment method is : " + payment
+ "\nYour comment about us : " + txtKomen.Text);
}

虽然我不确定 .Append.AppendNewLine() 是否存在于 StringBuilder 中,但它们可能在任何case Visual Studio 应该告诉你正确的名字。

关于c# - 如何在 C# 中将选中的复选框显示到消息框中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58090584/

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