Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to Lock First Column in Grid ??
Message
 
À
04/12/1999 05:56:39
Vinod Parwani
United Creations L.L.C.
Ad-Dulayl, Jordanie
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00298629
Message ID:
00299903
Vues:
24
>How to Lock First Column in Grid ?? Same way how we lock in browse window...
>
>TIA..

I need this capability too, so I did a search awhile back and found the following from Doug Hennig. I could not get it to work properly (my stupidity or some inherited methods are getting slammed) and I dont have the issue of FoxTalk that he references. You can try the things he suggests and see if you have any luck. I found my form could not be brought back up if I messed with the Partition property and panellink property that he referenced, but dont let that stop you from trying it. Please back up your form before trying it though.


***Dougs Post*******

In the July 97 issue of FoxTalk, I had an article that described a drill-down grid (like a TreeView control, but a grid showing data). This grid has the behavior you're describing: a locked column. Actually, it supports locking a number of leftmost columns, not just the first one; in fact, the article specifically locks the first two columns. You'll have to adjust this code for a single column.

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 <> 0 and .Panel = 1
Thisform.LockScreen = .T.
.Column3.SetFocus()
if .LeftColumn <> 3
.DoScroll(5)
endif .LeftColumn <> 3
Thisform.LockScreen = .F.
endif .Partition <> 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 <> 0 and .Panel = 0
.Panel = 1
.Column3.SetFocus()
endif .Partition <> 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


***END of Doug's Post
Bret Hobbs

"We'd have been called juvenile delinquents only our neighborhood couldn't afford a sociologist." Bob Hope
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform