0
所以我試圖從複選框中提取文本屬性並將其顯示到列表框中,但它似乎並不重要,如果它檢查或不是我做錯了什麼。從複選框中提取文本輸出
private void btnCompute_Click(object sender, EventArgs e)
{
string accessories = "";
if (chkChildSeat.Checked) ;
{
accessories = accessories + chkChildSeat.Text+",";
}
if (chkLockHelmet.Checked) ;
{
accessories = accessories + chkLockHelmet.Text+",";
}
if (chkTrailer.Checked) ;
{
accessories=accessories+chkTrailer.Text;
}
lstInvoice.Items.Add(String.Format("{0,-49}{1,-14}", "Invoice Date", DateTime.Now.ToString("d")));
lstInvoice.Items.Add(String.Format("{0,-50}{1,-13}", Customername, CustomerID));
lstInvoice.Items.Add(String.Format("{0,-49}{1,-14}", "Rental Date", dateTimePicker1.Value));
lstInvoice.Items.Add(string.Format("{0,-25}{1,-28}", "Accessories", accessories.ToString()));
lstInvoice.Items.Add(string.Format("{0,-49}{1,-14}", "Total Invoice Amount", result.ToString("c")));
}
這將顯示所有checkboxname.text屬性,而不考慮是否其檢查 誰能告訴我,爲什麼文字在列表框中截止更多選項進行檢查確實有一些與我的字符串.format行?
lstInvoice.Items.Add(string.Format("{0,-25}{1,-28}", "Accessories", accessories.ToString()));
哇,我在這個遊戲不好.... 感謝兄弟。 – 2014-09-25 07:53:27