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

📄 form1.frm

📁 实现如何进行数据导出
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Form1 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "范例-如何在 MSFlexGrid 中输入资料"
   ClientHeight    =   3030
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5055
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   3030
   ScaleWidth      =   5055
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame Frame1 
      Caption         =   "展示区"
      Height          =   2775
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   4815
      Begin VB.ComboBox Combo1 
         Height          =   300
         Left            =   2640
         TabIndex        =   3
         Text            =   "Combo1"
         Top             =   960
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.TextBox Text1 
         Height          =   300
         Left            =   120
         TabIndex        =   2
         Text            =   "Text1"
         Top             =   960
         Visible         =   0   'False
         Width           =   2055
      End
      Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
         Height          =   1575
         Left            =   120
         TabIndex        =   1
         Top             =   240
         Width           =   4575
         _ExtentX        =   8070
         _ExtentY        =   2778
         _Version        =   393216
         AllowBigSelection=   0   'False
         HighLight       =   0
         BorderStyle     =   0
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "Label1"
         Height          =   180
         Left            =   120
         TabIndex        =   4
         Top             =   1920
         Width           =   480
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' 影子整理 VB 爱好者乐园 yingzi007.126.com
Option Explicit

Private Sub Combo1_KeyPress(KeyAscii As Integer)
Dim i As Integer, bSame As Boolean
If KeyAscii = vbKeyEscape Then
    Combo1.Visible = False
    MSFlexGrid1.SetFocus
    Exit Sub
End If
If KeyAscii = vbKeyReturn Then
    MSFlexGrid1.Text = Combo1.Text
    Combo1.Visible = False
    MSFlexGrid1.SetFocus
    With Combo1
        bSame = False
        For i = 0 To .ListCount
            If .Text = .List(i) Then bSame = True
        Next i
        If Not bSame Then .AddItem .Text
    End With
End If
End Sub

Private Sub Combo1_LostFocus()
Combo1.Visible = False
MSFlexGrid1.SetFocus
End Sub

Private Sub Form_Load()
Dim i As Integer
With MSFlexGrid1
    .Cols = 5
    .Rows = 5
    For i = 0 To 4
        .RowHeight(i) = 300
    Next i
End With
For i = 1 To 10
    Combo1.AddItem i
Next i
Label1.Caption = "在第一、二行中,双击左键,会出现一文字框(TextBox)..." & vbCr & _
                 "而第三、四行,会出现选择类表单(ComboBox)..." & vbCr & _
                 "输入完毕后按下Enter键,资料即可保留于MSFlexGrid中," & vbCr & _
                 "而按下Esc键则取消输入..."
End Sub

Private Sub MSFlexGrid1_DblClick()
Dim c As Integer, r As Integer
With MSFlexGrid1
    c = .Col: r = .Row
    If c <= 2 Then
        Text1.Left = .Left + .ColPos(c)
        Text1.Top = .Top + .RowPos(r)
        Text1.Width = .ColWidth(c)
        Text1.Height = .RowHeight(r)
        Text1 = .Text
        Text1.Visible = True
        Text1.SetFocus
    Else
        Combo1.Left = .Left + .ColPos(c)
        Combo1.Top = .Top + .RowPos(r)
        Combo1.Width = .ColWidth(c)
        Combo1.Text = .Text
        Combo1.Visible = True
        Combo1.SetFocus
    End If
End With
End Sub

Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
    Call MSFlexGrid1_DblClick
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyEscape Then
    Text1.Visible = False
    MSFlexGrid1.SetFocus
    Exit Sub
End If
If KeyAscii = vbKeyReturn Then
    MSFlexGrid1.Text = Text1.Text
    Text1.Visible = False
    MSFlexGrid1.SetFocus
End If
End Sub

Private Sub Text1_LostFocus()
Text1.Visible = False
MSFlexGrid1.SetFocus
End Sub

⌨️ 快捷键说明

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