for the event handler, see the sample code in the documentation
DataGridBoolColumn.FalseValueChanged and TrueValueChanged Event
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsDataGridBoolColumnClassFalseValueChangedTopic.asp
Dim TblStyle As New DataGridTableStyle
Dim ColStyle As DataGridColumnStyle
Dim bColStyle As DataGridBoolColumn
Dim tbl As New DataTable
tbl = open_tab("SELECT userno,username FROM comm_user")
Dim cCurrent As New DataColumn("Current", GetType(Boolean))
cCurrent.AllowDBNull = False
tbl.Columns.Add(cCurrent)
DataGrid1.TableStyles.Clear()
With TblStyle
.ReadOnly = True
.AllowSorting = False
.GridColumnStyles.Clear()
.BackColor = System.Drawing.Color.AliceBlue
.AlternatingBackColor = System.Drawing.Color.MintCream
.HeaderBackColor = System.Drawing.Color.LightGray
.SelectionBackColor = System.Drawing.Color.PaleTurquoise
.SelectionForeColor = System.Drawing.Color.Red
.MappingName = "Comm_user" '这里少了关键一行,名称是不是这个你自己确定
End With
'第1列
bColStyle = New DataGridBoolColumn
With bColStyle
.AllowNull = False
.HeaderText = ""
.NullText = ""
.Width = 40
'.MappingName = tbl.Columns(2).ColumnName
.MappingName = "Current"
.Alignment = HorizontalAlignment.Center
End With
TblStyle.GridColumnStyles.Add(bColStyle)
'第2列
ColStyle = New DataGridTextBoxColumn
With ColStyle
.HeaderText = "期次"
.Width = 50
.ReadOnly = True
.NullText = ""
'.MappingName = tbl.Columns(1).ColumnName
.MappingName = "userno"
.Alignment = HorizontalAlignment.Center
End With
TblStyle.GridColumnStyles.Add(ColStyle)
'第3列
ColStyle = New DataGridTextBoxColumn
With ColStyle
.HeaderText = "号码"
.Width = 80
.ReadOnly = True
.NullText = ""
'.MappingName = tbl.Columns(2).ColumnName
.MappingName = "username"
.Alignment = HorizontalAlignment.Center
End With
TblStyle.GridColumnStyles.Add(ColStyle)
'TblStyle.GridColumnStyles.Add(ColStyle)
With DataGrid1
.DataSource = tbl
.TableStyles.Add(TblStyle)
.ColumnHeadersVisible = True
End With