home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 5 / MasteringVisualBasic5.iso / ch_code / ch07 / gridedit / gridedit.frm (.txt) next >
Encoding:
Visual Basic Form  |  1997-02-20  |  2.6 KB  |  87 lines

  1. VERSION 5.00
  2. Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
  3. Begin VB.Form Form1 
  4.    Caption         =   "Grid Edit"
  5.    ClientHeight    =   4620
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   7110
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   4620
  11.    ScaleWidth      =   7110
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.TextBox Text1 
  14.       Appearance      =   0  'Flat
  15.       Height          =   285
  16.       Left            =   2310
  17.       TabIndex        =   1
  18.       Top             =   45
  19.       Width           =   1230
  20.    End
  21.    Begin MSFlexGridLib.MSFlexGrid Grid1 
  22.       Height          =   3945
  23.       Left            =   225
  24.       TabIndex        =   0
  25.       Top             =   360
  26.       Width           =   6555
  27.       _ExtentX        =   11562
  28.       _ExtentY        =   6959
  29.       Rows            =   100
  30.       Cols            =   10
  31.       AllowUserResizing=   3
  32.    End
  33. Attribute VB_Name = "Form1"
  34. Attribute VB_GlobalNameSpace = False
  35. Attribute VB_Creatable = False
  36. Attribute VB_PredeclaredId = True
  37. Attribute VB_Exposed = False
  38. Private Sub Form_Load()
  39.     Grid1.Row = 1
  40.     Grid1.Col = 1
  41. End Sub
  42. Private Sub Grid1_EnterCell()
  43. ' Make sure the user doesn't attempt to edit the fixed cells
  44.     If Grid1.MouseRow = 0 Or Grid1.MouseCol = 0 Then
  45.         Text1.Visible = False
  46.         Exit Sub
  47.     End If
  48.     Grid1.Row = Grid1.MouseRow
  49.     Grid1.Col = Grid1.MouseCol
  50. ' clear contents of current cell
  51.     Text1.Text = ""
  52. ' place Textbox over current cell
  53.     Text1.Visible = False
  54.     Text1.Top = Grid1.Top + Grid1.CellTop
  55.     Text1.Left = Grid1.Left + Grid1.CellLeft
  56.     Text1.Width = Grid1.CellWidth
  57.     Text1.Height = Grid1.CellHeight
  58. ' assing cell's contents to Textbox
  59.     Text1.Text = Grid1.Text
  60. ' move focus to Textbox
  61.     Text1.Visible = True
  62.     Text1.SetFocus
  63. End Sub
  64. Private Sub Grid1_GotFocus()
  65. ' Make sure the user doesn't attempt to edit the fixed cells
  66.     If Grid1.MouseRow = 0 Or Grid1.MouseCol = 0 Then
  67.         Text1.Visible = False
  68.         Exit Sub
  69.     End If
  70.     Grid1.Row = Grid1.MouseRow
  71.     Grid1.Col = Grid1.MouseCol
  72. ' clear contents of current cell
  73.     Text1.Text = ""
  74. ' place Textbox over current cell
  75.     Text1.Top = Grid1.Top + Grid1.CellTop
  76.     Text1.Left = Grid1.Left + Grid1.CellLeft
  77.     Text1.Width = Grid1.CellWidth
  78.     Text1.Height = Grid1.CellHeight
  79. ' assing cell's contents to Textbox
  80.     Text1.Text = Grid1.Text
  81. ' move focus to Textbox
  82.     Text1.SetFocus
  83. End Sub
  84. Private Sub Grid1_LeaveCell()
  85.     Grid1.Text = Text1.Text
  86. End Sub
  87.