So i'm trying to extract the text property from a checkbox and displaying it into a listbox, but it seems like it doesn't matter if its checked or not what am i doing wrong.
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")));
}
this will display all the checkboxname.text properties regardless of whether or not its checked Could anyone tell me why the text is cutoff on the listbox as more options are checked does it has something to do with my string.format line?
lstInvoice.Items.Add(string.Format("{0,-25}{1,-28}", "Accessories", accessories.ToString()));