home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / EXCEL_like2080408212007.psc / flexgrid / Form1.frm next >
Text File  |  2007-04-05  |  10KB  |  383 lines

  1. VERSION 5.00
  2. Object = "{65E121D4-0C60-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCHRT20.OCX"
  3. Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
  4. Begin VB.Form Form1 
  5.    Appearance      =   0  'Flat
  6.    AutoRedraw      =   -1  'True
  7.    BackColor       =   &H80000005&
  8.    BorderStyle     =   1  'Fixed Single
  9.    Caption         =   "Form1"
  10.    ClientHeight    =   7395
  11.    ClientLeft      =   150
  12.    ClientTop       =   435
  13.    ClientWidth     =   10110
  14.    DrawWidth       =   2
  15.    LinkTopic       =   "Form1"
  16.    MaxButton       =   0   'False
  17.    MinButton       =   0   'False
  18.    ScaleHeight     =   7395
  19.    ScaleWidth      =   10110
  20.    StartUpPosition =   3  'Windows Default
  21.    WindowState     =   2  'Maximized
  22.    Begin Project1.ctxHookMenu ctxHookMenu1 
  23.       Left            =   1560
  24.       Top             =   5280
  25.       _ExtentX        =   900
  26.       _ExtentY        =   900
  27.       BmpCount        =   0
  28.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  29.          Name            =   "Tahoma"
  30.          Size            =   8.25
  31.          Charset         =   0
  32.          Weight          =   400
  33.          Underline       =   0   'False
  34.          Italic          =   0   'False
  35.          Strikethrough   =   0   'False
  36.       EndProperty
  37.    End
  38.    Begin MSChart20Lib.MSChart MSChart1 
  39.       Height          =   2415
  40.       Left            =   360
  41.       OleObjectBlob   =   "Form1.frx":0000
  42.       TabIndex        =   1
  43.       Top             =   6840
  44.       Visible         =   0   'False
  45.       Width           =   9855
  46.    End
  47.    Begin VB.TextBox txtEditor 
  48.       Height          =   495
  49.       Left            =   3600
  50.       TabIndex        =   0
  51.       Top             =   2160
  52.       Width           =   1215
  53.    End
  54.    Begin MSHierarchicalFlexGridLib.MSHFlexGrid MSFlexEditor 
  55.       Height          =   4695
  56.       Left            =   120
  57.       TabIndex        =   2
  58.       Top             =   240
  59.       Width           =   9855
  60.       _ExtentX        =   17383
  61.       _ExtentY        =   8281
  62.       _Version        =   393216
  63.       Rows            =   100
  64.       Cols            =   100
  65.       BackColorFixed  =   12648447
  66.       GridColorFixed  =   8454143
  67.       _NumberOfBands  =   1
  68.       _Band(0).Cols   =   100
  69.    End
  70.    Begin VB.Menu mnupopup 
  71.       Caption         =   "popup"
  72.       Visible         =   0   'False
  73.       Begin VB.Menu mnufreezeRW 
  74.          Caption         =   "Freeze Row"
  75.       End
  76.       Begin VB.Menu mnufrezeeCOL 
  77.          Caption         =   "Frezee Col"
  78.       End
  79.       Begin VB.Menu MnuFilldown 
  80.          Caption         =   "Fill Down"
  81.       End
  82.       Begin VB.Menu mnuChart 
  83.          Caption         =   "Chart"
  84.       End
  85.    End
  86. End
  87. Attribute VB_Name = "Form1"
  88. Attribute VB_GlobalNameSpace = False
  89. Attribute VB_Creatable = False
  90. Attribute VB_PredeclaredId = True
  91. Attribute VB_Exposed = False
  92. Dim ColNumber As Integer
  93. Dim RowNumber As Integer
  94. Dim currcol As Integer
  95. Dim currrow As Integer
  96.  
  97.  
  98.  
  99.  
  100. Private Sub Form_Load()
  101.     ' Setting The Height and Width of The TextBox to The Size of the Cells of the Flex Grid
  102.     txtEditor.Height = MSFlexEditor.CellHeight
  103.     txtEditor.Width = MSFlexEditor.CellWidth
  104.      
  105.     'Function for Setting the Left and Top of the TextBox to Tune of the Col and Row of the FlexGrid
  106.     Set_Flex_TextBox_Pos
  107. End Sub
  108.  
  109. Private Sub Form_Resize()
  110. MSFlexEditor.Width = Form1.Width - 250
  111.  
  112. MSFlexEditor.Height = Form1.Height - 4500
  113. End Sub
  114.  
  115. Private Sub mnuChart_Click()
  116. Dim i As Integer
  117. Dim j As Integer
  118. Dim col As Integer
  119. Dim row As Integer
  120.  
  121. MSChart1.TitleText = "Chart1"
  122.  
  123. With MSFlexEditor
  124. '      If .Row <> .RowSel Or .Col <> .ColSel Then
  125.          If .row < .RowSel Then
  126.             iLowRow = .row
  127.             iHiRow = .RowSel
  128.          Else
  129.             iLowRow = .RowSel
  130.             iHiRow = .row
  131.          End If
  132.          If .col < .ColSel Then
  133.             iLowCol = .col
  134.             iHiCol = .ColSel
  135.          Else
  136.             iLowCol = .ColSel
  137.             iHiCol = .col
  138.          End If
  139.  
  140. row = 1
  141.  
  142. MSChart1.RowCount = (iHiRow - iLowRow) + 1
  143. MSChart1.ColumnCount = (iHiCol - iLowCol) + 1
  144.  
  145.  
  146. For i = iLowRow To iHiRow
  147.       col = 1
  148.     For j = iLowCol To iHiCol
  149.           
  150.         MSChart1.row = row
  151.         MSChart1.Column = col
  152.         MSChart1.Data = Val(.TextMatrix(i, j))
  153.         MSChart1.RowLabel = "ROW" & i
  154.         MSChart1.ColumnLabel = "Col" & j
  155.         
  156.         col = col + 1
  157.     Next
  158.     row = row + 1
  159. Next
  160. 'MSChart1.Refresh
  161. MSChart1.chartType = 3
  162. MSChart1.Refresh
  163. MSChart1.Visible = True
  164.  
  165.  
  166.  
  167.  
  168. End With
  169.  
  170.  
  171.  
  172.  
  173.  
  174. End Sub
  175.  
  176. Private Sub MnuFilldown_Click()
  177. test
  178. End Sub
  179.  
  180. Private Sub mnufreezeRW_Click()
  181.  
  182.  MSFlexEditor.FixedRows = RowNumber + 1
  183.  If currcol < RowNumber Then
  184.     MSFlexEditor.row = RowNumber + 1
  185.     
  186.     If txtEditor.Visible Then
  187.      Set_Flex_TextBox_Pos
  188.     End If
  189.  
  190. Else
  191.       MSFlexEditor.row = currrow
  192. End If
  193.  
  194. End Sub
  195.  
  196. Private Sub mnufrezeeCOL_Click()
  197.    MSFlexEditor.FixedCols = ColNumber + 1
  198.   If currcol <= ColNumber Then
  199.   
  200.     MSFlexEditor.col = ColNumber + 1
  201.         
  202.     If txtEditor.Visible Then
  203.         Set_Flex_TextBox_Pos
  204.     End If
  205.   Else
  206.       MSFlexEditor.col = currcol
  207.   End If
  208.  
  209. End Sub
  210.  
  211. Private Sub MSFlexEditor_Click()
  212.     'Function for Setting the Left and Top of the TextBox to Tune of the Col and Row of the FlexGrid
  213.     txtEditor.Visible = True
  214.     Set_Flex_TextBox_Pos
  215.     
  216.    If txtEditor.Visible Then
  217.     txtEditor.SetFocus
  218.     End If
  219. End Sub
  220. Private Sub MSFlexEditor_KeyPress(KeyAscii As Integer)
  221.  
  222. ' If KeyAscii Then
  223.        txtEditor.Visible = True
  224.        Set_Flex_TextBox_Pos
  225.     
  226.     txtEditor.SetFocus
  227.  '   End If
  228.  
  229. End Sub
  230.  
  231. Private Sub MSFlexEditor_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  232.  
  233.  If Button = vbRightButton Then
  234.   ColNumber = MSFlexEditor.MouseCol
  235.                 RowNumber = MSFlexEditor.MouseRow
  236.  PopupMenu mnupopup
  237.  
  238.  End If
  239.  
  240. End Sub
  241.  
  242. Private Sub MSFlexEditor_Scroll()
  243. txtEditor.Visible = False
  244. End Sub
  245.  
  246. 'Private Sub MSFlexEditor_EnterCell()
  247. 'Set_Flex_TextBox_Pos
  248.     
  249.  '   txtEditor.SetFocus
  250. 'End Sub
  251.  
  252. Private Sub txtEditor_Change()
  253.     MSFlexEditor.Text = txtEditor.Text 'Setting the Text to the Active Cell
  254. End Sub
  255.  
  256. Private Sub txtEditor_KeyDown(KeyCode As Integer, Shift As Integer)
  257.     'Moving of the TextBox to the Tune of the Arrow Keys
  258.   Dim fixedcol As Integer
  259.   Dim fixedrow As Integer
  260.   
  261.   fixedcol = MSFlexEditor.FixedCols
  262.   fixedrow = MSFlexEditor.FixedRows
  263.   
  264.   
  265.     'left
  266.     If KeyCode = 37 Then
  267.         If Not MSFlexEditor.col <= fixedcol Then
  268.             MSFlexEditor.col = MSFlexEditor.col - 1
  269.             Set_Flex_TextBox_Pos
  270.         End If
  271.     End If
  272.     'down
  273.     
  274.     If KeyCode = 40 Then
  275.         If Not MSFlexEditor.row = MSFlexEditor.Rows - 1 Then
  276.             MSFlexEditor.row = MSFlexEditor.row + 1
  277.             Set_Flex_TextBox_Pos
  278.         End If
  279.     End If
  280.     
  281.     'up
  282.     If KeyCode = 38 Then
  283.         If Not MSFlexEditor.row <= fixedrow Then
  284.             MSFlexEditor.row = MSFlexEditor.row - 1
  285.             Set_Flex_TextBox_Pos
  286.         End If
  287.     End If
  288.     'right
  289.         If KeyCode = 39 Then
  290.         If Not MSFlexEditor.col = MSFlexEditor.Cols - 1 Then
  291.             MSFlexEditor.col = MSFlexEditor.col + 1
  292.             Set_Flex_TextBox_Pos
  293.         End If
  294.     End If
  295.   
  296.   If txtEditor.Visible Then
  297.     txtEditor.SetFocus
  298. End If
  299. End Sub
  300. Private Sub Set_Flex_TextBox_Pos()
  301.     'Setting Text Positions
  302.     txtEditor.Left = MSFlexEditor.CellLeft + MSFlexEditor.Left - 10
  303.     txtEditor.Top = MSFlexEditor.CellTop + MSFlexEditor.Top - 10
  304.     txtEditor.Text = MSFlexEditor.Text
  305.     currrow = MSFlexEditor.row
  306.     currcol = MSFlexEditor.col
  307. End Sub
  308.  
  309. Private Sub txtEditor_KeyPress(KeyAscii As Integer)
  310. If KeyAscii = 13 Then
  311.        txtEditor.Visible = True
  312.      If Not MSFlexEditor.row = MSFlexEditor.Rows - 1 Then
  313.             MSFlexEditor.row = MSFlexEditor.row + 1
  314.             Set_Flex_TextBox_Pos
  315.         End If
  316.     End If
  317.     txtEditor.SetFocus
  318. End Sub
  319.  
  320.  
  321. Private Sub test()
  322.  
  323.  With MSFlexEditor
  324. '      If .Row <> .RowSel Or .Col <> .ColSel Then
  325.          If .row < .RowSel Then
  326.             iLowRow = .row
  327.             iHiRow = .RowSel
  328.          Else
  329.             iLowRow = .RowSel
  330.             iHiRow = .row
  331.          End If
  332.          If .col < .ColSel Then
  333.             iLowCol = .col
  334.             iHiCol = .ColSel
  335.          Else
  336.             iLowCol = .ColSel
  337.             iHiCol = .col
  338.          End If
  339.            
  340.            
  341.      '      For k = iLowCol To iHiCol
  342.     '     .TextMatrix(0, k) = .TextMatrix(0, iLowCol)
  343.   
  344.   '                  If Str = "" Then
  345.    '                   Str = .TextMatrix(0, k)
  346.     '                Else
  347.      '                 Str = Str & vbTab & .TextMatrix(0, k)
  348.       '              End If
  349.            '   Next
  350.    '          Str = Str & vbCrLf
  351.                
  352.                
  353.                
  354.                
  355.          For i = iLowRow To iHiRow
  356.             For j = iLowCol To iHiCol
  357.                     
  358.           .TextMatrix(i, j) = .TextMatrix(iLowRow, iLowCol)
  359.                     
  360.          '   If j = iHiCol Then
  361.          '       Str = Str & .TextMatrix(i, j) & vbTab
  362.           '  Else
  363.            '   Str = Str & .TextMatrix(i, j) & vbTab
  364.             
  365.             
  366.            ' End If
  367.             
  368.             
  369.            Next
  370.            
  371.           'Str = Str & vbCrLf
  372.          Next
  373.          
  374. '      End If
  375.    End With
  376.   ' Clipboard.Clear
  377.   ' Clipboard.SetText Str
  378.  '  MousePointer = mp_Default
  379.  '  MsgBox "Copied to Clipbroad", vbInformation, "Copy"
  380.    Exit Sub
  381. End Sub
  382.  
  383.