home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
- Begin VB.Form GridEditForm
- Caption = "Grid Edit"
- ClientHeight = 4590
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 7275
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- LinkTopic = "Form1"
- ScaleHeight = 4590
- ScaleWidth = 7275
- StartUpPosition = 3 'Windows Default
- Begin VB.TextBox Text1
- Appearance = 0 'Flat
- BackColor = &H00FF0000&
- ForeColor = &H00FFFFFF&
- Height = 270
- Left = 60
- TabIndex = 1
- Top = 45
- Visible = 0 'False
- Width = 1590
- End
- Begin MSFlexGridLib.MSFlexGrid Grid1
- Height = 5415
- Left = 105
- TabIndex = 0
- Top = 90
- Width = 8385
- _ExtentX = 14790
- _ExtentY = 9551
- _Version = 393216
- Rows = 20
- Cols = 10
- AllowUserResizing= 3
- End
- Attribute VB_Name = "GridEditForm"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- ' ******************************
- ' ******************************
- ' ** MASTERING VB6 **
- ' ** by Evangelos Petroutos **
- ' ** SYBEX, 1998 **
- ' ******************************
- ' ******************************
- Private Sub Form_Load()
- Grid1.ColWidth(0) = TextWidth("99999")
- For i = 1 To Grid1.Rows - 1
- Grid1.TextMatrix(i, 0) = i
- Grid1.RowHeight(i) = 1.25 * Grid1.RowHeight(i)
- Next
- For i = 1 To Grid1.Cols - 1
- Grid1.TextMatrix(0, i) = Chr(64 + i)
- Next
- Grid1.Row = 1
- Grid1.Col = 1
- SetTextbox
- End Sub
- Private Sub Grid1_EnterCell()
- ' Make sure the user doesn't attempt to edit the fixed cells
- If Grid1.MouseRow = 0 Or Grid1.MouseCol = 0 Then
- Text1.Visible = False
- Exit Sub
- End If
- ' clear contents of current cell
- Text1.Text = ""
- ' place Textbox over current cell
- Text1.Visible = False
- Text1.Top = Grid1.Top + Grid1.CellTop
- Text1.Left = Grid1.Left + Grid1.CellLeft
- Text1.Width = Grid1.CellWidth
- Text1.Height = Grid1.CellHeight
- ' assing cell's contents to Textbox
- Text1.Text = Grid1.Text
- ' move focus to Textbox
- Text1.Visible = True
- Text1.SetFocus
- End Sub
- Private Sub Grid1_LeaveCell()
- Grid1.Text = Text1.Text
- End Sub
- Private Sub Text1_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- If Grid1.Row = Grid1.Rows - 1 Then
- If Grid1.Col = Grid1.Cols - 1 Then
- Exit Sub
- Else
- Grid1.Col = Grid1.Col + 1
- End If
- Grid1.Row = 1
- Else
- Grid1.Row = Grid1.Row + 1
- End If
- End If
- End Sub
- Sub SetTextbox()
- Text1.Visible = False
- Text1.Top = Grid1.Top + Grid1.CellTop
- Text1.Left = Grid1.Left + Grid1.CellLeft
- Text1.Height = Grid1.CellHeight
- Text1.Width = Grid1.CellWidth
- Text1.Text = Grid1.Text
- Text1.Visible = True
- End Sub
-