⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.vb

📁 cflexgrid的功能运用 整表更新数据库
💻 VB
字号:
Imports C1.Win.C1FlexGrid

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    Friend WithEvents fg As C1.Win.C1FlexGrid.C1FlexGrid

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
        Me.fg = New C1.Win.C1FlexGrid.C1FlexGrid()
        CType(Me.fg, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'fg
        '
        Me.fg.ColumnInfo = "5,1,0,0,0,85,Columns:"
        Me.fg.Dock = System.Windows.Forms.DockStyle.Fill
        Me.fg.Name = "fg"
        Me.fg.Rows.DefaultSize = 17
        Me.fg.Size = New System.Drawing.Size(400, 273)
        Me.fg.StyleInfo = "Normal{Font:Microsoft Sans Serif, 8.25pt;}" & Microsoft.VisualBasic.ChrW(9) & "Alternate{}" & Microsoft.VisualBasic.ChrW(9) & "Fixed{BackColor:Control;Fo" & _
        "reColor:ControlText;Border:Flat,1,ControlDark,Both;}" & Microsoft.VisualBasic.ChrW(9) & "Highlight{BackColor:Highlig" & _
        "ht;ForeColor:HighlightText;}" & Microsoft.VisualBasic.ChrW(9) & "Focus{}" & Microsoft.VisualBasic.ChrW(9) & "Editor{}" & Microsoft.VisualBasic.ChrW(9) & "Search{BackColor:Highlight;ForeCol" & _
        "or:HighlightText;}" & Microsoft.VisualBasic.ChrW(9) & "Frozen{BackColor:LightBlue;}" & Microsoft.VisualBasic.ChrW(9) & "NewRow{}" & Microsoft.VisualBasic.ChrW(9) & "EmptyArea{BackColor:App" & _
        "Workspace;Border:Flat,1,ControlDarkDark,Both;}" & Microsoft.VisualBasic.ChrW(9) & "SelectedColumnHeader{}" & Microsoft.VisualBasic.ChrW(9) & "SelectedRo" & _
        "wHeader{}" & Microsoft.VisualBasic.ChrW(9) & "GrandTotal{BackColor:Black;ForeColor:White;}" & Microsoft.VisualBasic.ChrW(9) & "Subtotal0{BackColor:Contr" & _
        "olDarkDark;ForeColor:White;}" & Microsoft.VisualBasic.ChrW(9) & "Subtotal1{BackColor:ControlDarkDark;ForeColor:White" & _
        ";}" & Microsoft.VisualBasic.ChrW(9) & "Subtotal2{BackColor:ControlDarkDark;ForeColor:White;}" & Microsoft.VisualBasic.ChrW(9) & "Subtotal3{BackColor:Con" & _
        "trolDarkDark;ForeColor:White;}" & Microsoft.VisualBasic.ChrW(9) & "Subtotal4{BackColor:ControlDarkDark;ForeColor:Whi" & _
        "te;}" & Microsoft.VisualBasic.ChrW(9) & "Subtotal5{BackColor:ControlDarkDark;ForeColor:White;}" & Microsoft.VisualBasic.ChrW(9)
        Me.fg.TabIndex = 0
        Me.fg.Tree.LineColor = System.Drawing.Color.FromArgb(CType(128, Byte), CType(128, Byte), CType(128, Byte))
        Me.fg.Tree.NodeImageCollapsed = CType(resources.GetObject("fg.Tree.NodeImageCollapsed"), System.Drawing.Bitmap)
        Me.fg.Tree.NodeImageExpanded = CType(resources.GetObject("fg.Tree.NodeImageExpanded"), System.Drawing.Bitmap)
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(400, 273)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.fg})
        Me.Name = "Form1"
        Me.Text = "Form1"
        CType(Me.fg, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        ' set up columns
        Dim cols As String = "Product|Region|Salesperson|Sales|Bonus"
        Dim colNames As String() = cols.Split("|")
        Dim i%
        For i = 0 To fg.Cols.Count - 1
            fg(0, i) = colNames(i)
            fg.Cols(i).Name = colNames(i)
        Next

        ' set column DataType and Format 
        Dim c As Column = fg.Cols("Sales")
        c.DataType = GetType(Decimal)
        c.Format = "c" ' << currency

        c = fg.Cols("Bonus")
        c.DataType = GetType(Boolean)
        c.ImageAlign = ImageAlignEnum.CenterCenter

        ' set up drop-down lists
        fg.Cols("Product").ComboList = "Applets|Wahoos|Gadgets"
        fg.Cols("Region").ComboList = "North|South|East|West"
        fg.Cols("Salesperson").ComboList = "|Mary|Paula|Sarah"

        Exit Sub

        ' test DataMap property
        Dim dm As System.Collections.Specialized.ListDictionary
        dm = New System.Collections.Specialized.ListDictionary()
        dm.Add(1, "Full time")
        dm.Add(23, "Part Time")
        dm.Add(65, "Contractor")
        dm.Add(0, "Other")
        fg.Cols("Salesperson").DataMap = dm

    End Sub

    Private Sub fg_ValidateEdit(ByVal sender As Object, ByVal e As C1.Win.C1FlexGrid.ValidateEditEventArgs) Handles fg.ValidateEdit
        Dim rgn As String, prd As String

        ' collect the data we need
        Select Case e.Col
            Case 0
                prd = fg.Editor.Text
                rgn = fg(e.Row, "Region")
            Case 1
                prd = fg(e.Row, "Product")
                rgn = fg.Editor.Text
        End Select

        ' we can't sell Applets in the North Region...
        If prd = "Applets" And rgn = "North" Then
            MsgBox("Warning: Regulation #12333AS/SDA-23 forbids " & _
                   "the sale of " & prd & " in region " & rgn & ". " & _
                   "Please verify input.")
            e.Cancel = True
        End If

    End Sub

    Private Sub fg_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles fg.KeyDown
        Dim copy As Boolean, paste As Boolean

        ' copy: ctrl-C, ctrl-X, ctrl-ins
        If e.Control Then
            If e.KeyCode = Keys.C Or e.KeyCode = Keys.X Or _
               e.KeyCode = Keys.Insert Then
                copy = True
            End If
        End If

        ' paste: ctrl-V, shift-ins
        If (e.Control = True And e.KeyCode = Keys.V) Or _
           (e.Shift And e.KeyCode = Keys.Insert) Then
            paste = True
        End If

        ' copy selection to clipboard
        If copy Then
            Clipboard.SetDataObject(fg.Clip)
        End If

        ' paste from clipboard
        If paste Then

            ' see of there's text in the clipboard
            Dim data As IDataObject = Clipboard.GetDataObject()
            If data.GetDataPresent(DataFormats.Text) Then

                ' there is, so paste it
                fg.Select(fg.Row, fg.Col, fg.Rows.Count - 1, fg.Cols.Count - 1, False)
                fg.Clip = CType(data.GetData(DataFormats.Text), String)
                fg.Select(fg.Row, fg.Col)

            End If
        End If
    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -