Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Multi-panel grids: How do I...?
Message
De
07/09/2000 15:11:09
Jill Derickson
Software Specialties
Saipan, CNMI
 
 
À
07/09/2000 11:13:18
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00413542
Message ID:
00413796
Vues:
13
George:

>I have a grid with two panels. I want to show the student's name on the left and a list of class dates on the right. So the students' names will stay there even if the user is on the far right of the classes.

I just finished doing this, w/help from an article by Doug Henning, and it works pretty nicely. Here is what he wrote:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It's not easy, but here are the details for the grid class:

- Set the Partition property to an approximate value; it will be set at runtime to the proper value.

- Init() sets the left panel to not have a scroll bar. This can't be done at design time, so the grid will appear to have two vertical scroll bars. At runtime, however, this code eliminates the scroll bar for the left panel, making the grid look more like an Excel spreadsheet with a frozen panel. Init() also adjusts the partition position so the left panel just includes the first two columns:
with This
  .PanelLink  = .F.
  .Panel      = 0
  .ScrollBars = 1
  .Panel      = 1
  .PanelLink  = .T.
  .Partition  = .Column1.Width + .Column2.Width + 2
endwith
- Scrolled(), which is fired whenever the user scrolls the grid, ensures the appropriate columns are displayed in the appropriate panel by forcing the grid to scroll unwanted columns out of view if necessary.
LPARAMETERS nDirection
local lnI
Thisform.LockScreen = .T.
with This
  do case

* If either of the first two columns is visible in the
* right panel, scroll until they're no longer there.

    case .Panel = 1 and .LeftColumn <= 3
      for lnI = .LeftColumn to 2
        .DoScroll(5)
      next lnI

* If any column but the first two is visible in the left
* panel, scroll until they're no longer there.

    case .Panel = 0 and .LeftColumn > 1
      for lnI = .LeftColumn to 2 step - 1
        .DoScroll(4)
      next lnI
  endcase
endwith
Thisform.LockScreen = .F.
- Column1.Text1.GotFocus() ensures the right panel doesn't show the first two columns by setting focus to column 3 (the first column in the right panel) if necessary. This makes the grid act more like a spreadsheet.
with This.Parent.Parent
  if .Partition &lt;> 0 and .Panel = 1
    Thisform.LockScreen = .T.
    .Column3.SetFocus()
    if .LeftColumn &lt;> 3
      .DoScroll(5)
    endif .LeftColumn &lt;> 3
    Thisform.LockScreen = .F.
  endif .Partition &lt;> 0 ...
endwith
- Column1.Text1.LostFocus() moves to the third column (the first column we want displayed in the right panel). This makes the grid act more like a spreadsheet.
with This.Parent.Parent
  if .Partition &lt;> 0 and .Panel = 0
    .Panel = 1
    .Column3.SetFocus()
  endif .Partition &lt;> 0 ...
endwith
- Column2.Text1.When() prevents focus from being set to the Name column:
return .F.
- The columns in the right panel (column 3 and higher) contain a textbox class with the following When code to prevents the textbox from receiving focus if there isn't a partition or if focus is in the left panel:
with This.Parent.Parent
  return .Partition = 0 or .Panel = 1
endwith
Kind of ugly, but it works :)

Doug

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Good luck! J
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform