views:

237

answers:

1
Dim Comp = From C In db.Table1 _
Select C.Completed, C.Taken, C.Namne

Datagridview1.DataSource = Comp

Am using the Entity Framework and Columns Completed and Taken are of bit Datatype. When the query results are displayed in the datagridview, these bit columns are returned as of ColumnType Textbox - so i get a Datagridview textbox column with true or false string values.

I want to display Completed and Taken as Checkbox columns (either ticked for True or un-ticked for false) but ofcourse i can't do this in EditColumn dialogue because the Datagridview is unbound.

how can i change this in code at runtime

A: 

Edit:

I just looked at your code again and I realised that what you actually mean is that the DGV is bound rather than unbound? Since you're binding it to Comp.

If I understand correctly, just create 3 columns in the DGV at design time, 1 DataGridViewTextBoxColumn and 2 DataGridViewCheckBoxColumn. Then set the DataPropertyName of each column (Completed or Taken for the checkbox columns etc).

If the DataPropertyNames are correct the data will appear in them (if they're not correct, you'll end up with 6 columns in total).

ho1
how can i change the column type of a unbound Datagridview? There are no columns at design time!
Name.IsNullOrEmpty
I don't understand what you mean with unbound and why you don't have any columns at design time? Whenever I've used a DGV I always add it to the form and then insert the columns manually, then I either load the data manually or bind it to a DataTable. Either way, I create the columns first. How is the DGV populated with columns?
ho1