home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / multigrd / multigrd.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-06  |  4.0 KB  |  131 lines

  1. VERSION 2.00
  2. Begin Form MultiGrd 
  3.    Caption         =   "Comments To: 71201,2304"
  4.    ClientHeight    =   5340
  5.    ClientLeft      =   1755
  6.    ClientTop       =   1635
  7.    ClientWidth     =   4140
  8.    Height          =   5745
  9.    Left            =   1695
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   5340
  12.    ScaleWidth      =   4140
  13.    Top             =   1290
  14.    Width           =   4260
  15.    Begin ListBox List1 
  16.       ForeColor       =   &H00FF0000&
  17.       Height          =   1590
  18.       Left            =   375
  19.       TabIndex        =   4
  20.       Top             =   3060
  21.       Width           =   3285
  22.    End
  23.    Begin CommandButton ShowBtn 
  24.       Caption         =   "Show"
  25.       Height          =   400
  26.       Left            =   405
  27.       TabIndex        =   2
  28.       Top             =   4785
  29.       Width           =   1000
  30.    End
  31.    Begin CommandButton EndBtn 
  32.       Caption         =   "End"
  33.       Height          =   400
  34.       Left            =   2655
  35.       TabIndex        =   1
  36.       Top             =   4770
  37.       Width           =   1000
  38.    End
  39.    Begin Grid Grid1 
  40.       FixedCols       =   0
  41.       FixedRows       =   0
  42.       Height          =   2004
  43.       Left            =   945
  44.       Rows            =   8
  45.       TabIndex        =   0
  46.       Top             =   105
  47.       Width           =   2310
  48.    End
  49.    Begin Label Label1 
  50.       Alignment       =   2  'Center
  51.       BorderStyle     =   1  'Fixed Single
  52.       Caption         =   "Label1"
  53.       Height          =   720
  54.       Left            =   75
  55.       TabIndex        =   3
  56.       Top             =   2190
  57.       Width           =   3945
  58.    End
  59. DefInt A-Z
  60. '   This demo program illustrates how one can select
  61. '   non-adjascent rows of a grid for further processing.
  62. '   Running the program will populate the Grid with some data.
  63. '   You can then click on any column of EACH Row that you want
  64. '   to select.  When a row is selected, a ">" symbol appears in
  65. '   the first column.  To de-select a row, click on it again,
  66. '   and the ">" symbol disappears to indicate that the row is
  67. '   de-selected.
  68. '   After you have selected all the rows that you want,
  69. '   press the "SHOW" Button.  The Items in Column 1 of the
  70. '   selected rows only will be added to the list box,
  71. '   as proof that the method works.
  72. '   Pressing the "END" Button ends the Program.
  73. '   Questions and Comments can be addressed to:
  74. Dim Shared Beers(0 To 7) As String
  75. Sub EndBtn_Click ()
  76.     End
  77. End Sub
  78. Sub Form_Load ()
  79.     CRLF$ = Chr$(13) + Chr$(10)
  80.     Label1.Visible = False
  81. '   Sample Data for Grid
  82.         Beers(0) = "Michelob"
  83.         Beers(1) = "Budweiser"
  84.         Beers(2) = "Bush"
  85.         Beers(3) = "Corona Extra"
  86.         Beers(4) = "Heineken"
  87.         Beers(5) = "Fosters"
  88.         Beers(6) = "Miller"
  89.         Beers(7) = "HomeBrew"
  90. '   Populate the grid
  91.         grid1.Col = 1
  92.         For r = 0 To 7
  93.             grid1.Row = r
  94.             grid1.Text = Beers(r)
  95.         Next r
  96. '   Adjust grid for display
  97.         grid1.ColWidth(0) = 250
  98.         grid1.ColWidth(1) = 2000
  99.         grid1.Width = 2310
  100.         grid1.Height = 1950
  101.         
  102. '   Display Instructions
  103.         Label1.Caption = "Click on one or more rows to select" & CRLF$
  104.         Label1.Caption = Label1.Caption & "Click again to de-select" & CRLF$
  105.         Label1.Caption = Label1.Caption & "Press SHOW Button when done selecting"
  106.         Label1.Visible = True
  107. End Sub
  108. Sub Grid1_Click ()
  109.     grid1.Col = 0
  110.     If grid1.Text = ">" Then
  111.         grid1.Text = ""
  112.     Else
  113.         grid1.Text = ">"
  114.     End If
  115. End Sub
  116. Sub ShowBtn_Click ()
  117.     list1.Clear     '  Clear the List from possible
  118.                     '  prior usage
  119. '   Add Array item to list box if corresponding
  120. '   row in grid was selected
  121.     grid1.Col = 0
  122.     For i = 0 To 7
  123.         grid1.Row = i
  124.         If grid1.Text = ">" Then list1.AddItem Beers(i)
  125.     Next i
  126. '   If list is empty, display appropriate message
  127.     If list1.ListCount = 0 Then
  128.         list1.AddItem "No Rows of Grid Were Selected!!"
  129.     End If
  130. End Sub
  131.