1.当要绑定的数据为0,1数据时:
Me.Chkdata.DataBindings.Add("Checked", DataView, "字段")
2.当要绑定的数据为Y,N等字符时(以Y,N为例)
(1) Load事件
ii = Me.BindingContext(objDvSos).Position
If ii < 0 Then
Exit Sub
End If
Me.Chkdata.Checked = IIf(objDvSos(ii).Item("IsShow") = "Y", True, False)
(2)还要DataGrid的CurrentCellChanged事件里处理
Private Sub DgdGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DgdGrid1.CurrentCellChanged
ii = Me.BindingContext(objDvprintinfor).Position
Me.Chkdata.Checked = IIf(objDvprintinfor(ii).Item("Is_no_data") = "Y", True, False)
![](/Images/OutliningIndicators/InBlock.gif)
End Sub
总结: 很明显,当字段为01时很方便,从另一个侧面说明数据库设计的重要性
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
2.当要绑定的数据为Y,N等字符时(以Y,N为例)
(1) Load事件
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
(2)还要DataGrid的CurrentCellChanged事件里处理
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
总结: 很明显,当字段为01时很方便,从另一个侧面说明数据库设计的重要性