|
-
Sep 14th, 2020, 12:08 PM
#1
Thread Starter
Addicted Member
[RESOLVED] DataGridViewCheckBoxColumn from SQL bit type
I am looking for a method to convert a SQL bit column (0, 1, NULL) queried into a DataGridViewCheckBoxColumn without using a loop. I tried:
VB.NET Code:
Dim cell As DataGridViewCell = New DataGridViewCheckBoxCell()
With DataGridView2
With .Columns("FLY")
.CellTemplate = cell
End With
End With
which resulted in the error: "An unhandled exception of type 'System.InvalidCastException' occurred in System.Windows.Forms.dll. Additional information: Value provided for CellTemplate must be of type System.Windows.Forms.DataGridViewTextBoxCell or derive from it."
I believe this has to do with the 3 state value of the bit type in the SQL column (0, 1, NULL). I also thought maybe to CAST the SQL value to a text value, but wasn't sure of the syntax. What is the best way to go about this and avoid the loop? Perhaps if the data only had 0,1 then VB.net would automatically convert this to TRUE/FALSE and display the Checkbox in the DataGridView?
Last edited by Fedaykin; Sep 14th, 2020 at 12:14 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|