Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grids - Multi-select - Is it possible?
Message
From
05/03/2008 10:36:24
 
 
To
05/03/2008 08:42:40
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01298851
Message ID:
01298916
Views:
27
With a grid in vfp8, is it possible to get it to do multi-selection of the records?

Can you point me to some examples?


This is an example from Chapter 6 of 1001 Things You Wanted to Know About Visual FoxPro. The code is a bit old because the book was written for VFP 6, so some of the stuff (like the code to highlight the current grid row) is no longer required.

HTH
**************************************************
*-- Form:         frmselgrid
Define Class frmselgrid As frmsample
  Top = -4
  Left = 0
  Height = 452
  Width = 632
  DoCreate = .T.
  Caption = "Multi-Select Grid Example With Incremental Search"
  cprimarytable = "lv_Customer"
  Name = "frmSelGrid"
  cmdPrevious.Top = 378
  cmdPrevious.Left = 21
  cmdPrevious.Name = "cmdPrevious"
  cmdExit.Top = 378
  cmdExit.Left = 540
  cmdExit.Name = "cmdExit"
  cmdNext.Top = 378
  cmdNext.Left = 104
  cmdNext.Name = "cmdNext"

  Add Object grdcustomer As grdbase With ;
    ColumnCount = 5, ;
    Height = 236, ;
    Left = 9, ;
    Panel = 1, ;
    RecordSource = "lv_customer", ;
    RecordSourceType = 1, ;
    Top = 119, ;
    Width = 615, ;
    Name = "grdCustomer", ;
    Column1.ColumnOrder = 2, ;
    Column1.ControlSource = "lv_customer.company", ;
    Column1.Width = 187, ;
    Column1.ReadOnly = .T., ;
    Column1.Name = "colCompany", ;
    Column2.ColumnOrder = 3, ;
    Column2.ControlSource = "lv_customer.contact", ;
    Column2.Width = 141, ;
    Column2.ReadOnly = .T., ;
    Column2.Name = "colContact", ;
    Column3.ColumnOrder = 4, ;
    Column3.ControlSource = "lv_customer.country", ;
    Column3.Width = 107, ;
    Column3.ReadOnly = .T., ;
    Column3.Name = "colCountry", ;
    Column4.ColumnOrder = 5, ;
    Column4.ControlSource = "lv_customer.phone", ;
    Column4.Width = 112, ;
    Column4.Name = "colPhone", ;
    Column5.ColumnOrder = 1, ;
    Column5.ControlSource = "lv_customer.lselected", ;
    Column5.Width = 32, ;
    Column5.Sparse = .F., ;
    Column5.Name = "collSelected"

  Add Object frmselgrid.grdcustomer.colcompany.hdrcompany As Header With ;
    Caption = "Company", ;
    Name = "hdrCompany"

  Add Object frmselgrid.grdcustomer.colcompany.txtseachcompany As txtsearchgrid With ;
    Left = 73, ;
    ReadOnly = .T., ;
    Top = 44, ;
    Name = "txtSeachCompany"

  Add Object frmselgrid.grdcustomer.colcontact.hdrcontact As Header With ;
    Caption = "Contact ", ;
    Name = "hdrContact"

  Add Object frmselgrid.grdcustomer.colcontact.txtsearchcontact As txtsearchgrid With ;
    Left = 62, ;
    Top = 78, ;
    Name = "txtSearchContact"

  Add Object frmselgrid.grdcustomer.colcountry.hdrcountry As Header With ;
    Caption = "Country", ;
    Name = "hdrCountry"

  Add Object frmselgrid.grdcustomer.colcountry.txtsearchcountry As txtsearchgrid With ;
    Left = 58, ;
    Top = 71, ;
    Width = 1, ;
    Name = "txtSearchCountry"

  Add Object frmselgrid.grdcustomer.colphone.hdrphone As Header With ;
    Caption = "Phone", ;
    Name = "hdrPhone"

  Add Object frmselgrid.grdcustomer.colphone.txtphone As TextBox With ;
    BorderStyle = 0, ;
    Margin = 0, ;
    ReadOnly = .F., ;
    ForeColor = Rgb(0,0,0), ;
    BackColor = Rgb(255,255,255), ;
    Name = "txtPhone"

  Add Object frmselgrid.grdcustomer.collselected.hdrlselected As Header With ;
    Caption = "", ;
    Name = "hdrlSelected"

  Add Object frmselgrid.grdcustomer.collselected.chkselected As Checkbox With ;
    Top = 55, ;
    Left = 18, ;
    Height = 17, ;
    Width = 60, ;
    Picture = "cross.bmp", ;
    DownPicture = "check.bmp", ;
    Caption = "", ;
    Style = 1, ;
    ReadOnly = .F., ;
    Name = "chkSelected"

  Add Object txttitle As txtbase With ;
    ControlSource = "lv_customer.title", ;
    Height = 23, ;
    Left = 58, ;
    MaxLength = 30, ;
    TabIndex = 13, ;
    Top = 14, ;
    Width = 218, ;
    Name = "txtTitle"

  Add Object lbltitle As Label With ;
    AutoSize = .T., ;
    WordWrap = .T., ;
    BackStyle = 0, ;
    Caption = "Title", ;
    Left = 31, ;
    Top = 18, ;
    Width = 23, ;
    TabIndex = 12, ;
    Name = "lblTitle"

  Add Object txtaddress As txtbase With ;
    ControlSource = "lv_customer.address", ;
    Height = 23, ;
    Left = 58, ;
    MaxLength = 60, ;
    TabIndex = 15, ;
    Top = 46, ;
    Width = 428, ;
    Name = "txtAddress"

  Add Object lbladdress As Label With ;
    AutoSize = .T., ;
    WordWrap = .T., ;
    BackStyle = 0, ;
    Caption = "Address", ;
    Left = 10, ;
    Top = 50, ;
    Width = 46, ;
    TabIndex = 14, ;
    Name = "lblAddress"

  Add Object txtcity As txtbase With ;
    Comment = "", ;
    ControlSource = "lv_customer.city", ;
    Height = 23, ;
    Left = 58, ;
    MaxLength = 15, ;
    TabIndex = 17, ;
    Top = 78, ;
    Width = 113, ;
    Name = "txtCity"

  Add Object lblcity As Label With ;
    AutoSize = .T., ;
    WordWrap = .T., ;
    BackStyle = 0, ;
    Caption = "City", ;
    Left = 35, ;
    Top = 82, ;
    Width = 20, ;
    TabIndex = 16, ;
    Name = "lblCity"

  Procedure grdcustomer.setgrid
    DoDefault()
    *** Set up for highlighting ALL Selected Rows
    This.SetAll( 'DynamicForeColor', ;
      'IIF( lSelected, RGB( 0, 0, 128 ), RGB( 0, 0, 0 ) )', 'COLUMN' )
    This.SetAll( 'DynamicBackColor', ;
      'IIF( lSelected, RGB( 0,255,255 ), RGB( 255, 255, 255 ) )', 'COLUMN' )
    Go Bottom In (This.RecordSource )
  Endproc

  Procedure grdcustomer.AfterRowColChange
    Lparameters nColIndex
    With This.Parent
      .txttitle.Refresh()
      .txtaddress.Refresh()
      .txtcity.Refresh()
    Endwith
  Endproc

  Procedure txtphone.When
    With This.Parent.Parent
      .nRecNo = Recno( .RecordSource )
    Endwith
  Endproc

  Procedure chkselected.Click
    DoDefault()
    Keyboard '{DNARROW}'
  Endproc

Enddefine
Previous
Reply
Map
View

Click here to load this message in the networking platform