Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to bind a boolean value to checkboxcolumn datagrid WPF
    primarykey
    data
    text
    <p>i'm working on a project at a company for school and I have to make a datagrid with ticketinformation: The id-number, description of a ticket.</p> <p>In my Tickettable in the database, I have a column 'Item' and it can have the values: "Not to be invoiced","To be invoiced" or "Offer". The 3rd column in the datagrid has to be a checkboxcolumn and my boss wants me that there is a possibility to check the checkbox, that means the ticket has to be invoiced, and when I uncheck, it means "not to be invoiced" or "offer", that doesn't really matter. My problem is when I bind the "ID" and "Description"-fields, I don't know how to bind the checkboxcolumn with a 'true or false' field? I only know how to bind tablefields from Ticket, but I want to add a boolean-field so I can determine in code when it's "to be invoiced", my boolean-field has to be true and when it's not to be invoiced, it has to be false, so unchecked.</p> <pre><code>dgTickets.DataContext = new List&lt;ISSUE&gt;(); dgTickets.Columns.Add(new DataGridTextColumn { Header = "Id", Binding = new Binding("IM_ISSUE_NO") }); dgTickets.Columns.Add(new DataGridTextColumn { Header = "Description", Binding = new Binding("IM_DESCRIPTION") }); DataGridCheckBoxColumn chk = new DataGridCheckBoxColumn(); chk.Header = "To be invoiced?"; List&lt;ISSUE&gt; lTickets = new List&lt;ISSUE&gt;(); lTickets = _ISSUEBO.getTickets(); //here I want to make a list of booleans when the tickets are 'to be invoiced or not' in the database List&lt;bool&gt; lChecks = new List&lt;bool&gt;(); int intTeller = 0; bool boolFact = false; foreach (ISSUE i in lTickets) { switch (i.IM_ITEM_CODE) { case "TO BE INVOICED": boolFact = true; break; case "NOT TB INVOICED": boolFact = false; break; case "OFFER": boolFact = false; break; default: break; } lChecks.Add(boolFact); intTeller++; } Binding b = new Binding("lChecks"); //??? this is probably wrong, but i don't know how to do chk.Binding = b; this.dgTickets.Columns.Add(chk); dgTickets.ItemsSource = lTickets; </code></pre> <p>Can anyone help me please?</p> <p>Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload