在新的窗体中放入C1TrueDBGrid,然后追加以下代码(VB)
- Protected Overrides Sub OnLoad(e As EventArgs)
- MyBase.OnLoad(e)
- Dim dt As New DataTable
- dt.Columns.Add("id", GetType(Int64))
- dt.Columns.Add("name", GetType(String))
- dt.Columns.Add("birthday", GetType(String))
- dt.Columns.Add("married", GetType(Boolean))
- dt.Rows.Add(1, "", "", False)
- dt.Rows.Add(2, "R1234", "2018/10/25", True)
- dt.Rows.Add(3, "R12345", "2018/10/25", False)
- Me.C1TrueDBGrid1.Columns.Clear()
- Dim dc As C1DataColumn
- dc = New C1DataColumn
- Me.C1TrueDBGrid1.Columns.Add(dc)
- dc.DataType = GetType(Int64)
- dc.DataField = "id"
- dc.NumberFormat = "###,###"
- dc.Caption = "id"
- Me.C1TrueDBGrid1.Splits(0).DisplayColumns(0).Visible = True
- dc = New C1DataColumn
- Me.C1TrueDBGrid1.Columns.Add(dc)
- dc.DataType = GetType(String)
- dc.DataField = "name"
- dc.Caption = "name"
- Me.C1TrueDBGrid1.Splits(0).DisplayColumns(1).Visible = True
- dc = New C1DataColumn
- Me.C1TrueDBGrid1.Columns.Add(dc)
- dc.DataType = GetType(String)
- dc.DataField = "birthday"
- dc.NumberFormat = ""
- dc.EditMaskUpdate = True
- dc.EditMask = "0000/00/00"
- dc.Caption = "birthday"
- Me.C1TrueDBGrid1.Splits(0).DisplayColumns(2).Visible = True
- dc = New C1DataColumn
- Me.C1TrueDBGrid1.Columns.Add(dc)
- dc.DataType = GetType(Boolean)
- dc.DataField = "married"
- dc.ValueItems.Presentation = PresentationEnum.CheckBox
- dc.Caption = "married"
- Me.C1TrueDBGrid1.Splits(0).DisplayColumns(3).Visible = True
- Me.C1TrueDBGrid1.SetDataBinding(dt, Nothing, True)
- With C1TrueDBGrid1
- .MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.HighlightCell
- .AllowAddNew = False
- .AllowUpdate = True
- .AllowDelete = False
- .AllowRowSelect = True
- .AllowColSelect = False
- .AllowArrows = True
- .TabAction = C1.Win.C1TrueDBGrid.TabActionEnum.GridNavigation
- .WrapCellPointer = True
- End With
- End Sub
- Private Sub C1TrueDBGrid1_BeforeColUpdate(sender As Object, e As BeforeColUpdateEventArgs) Handles C1TrueDBGrid1.BeforeColUpdate
- Console.WriteLine("NewValue:'{0}', OldValue:'{1}'", e.Column.DataColumn.Value.ToString, e.OldValue.ToString)
- End Sub
复制代码 |