Solved

Another VFP 6 grid question

Posted on 2010-09-15
12
951 Views
Last Modified: 2012-08-13
Hi guys, so I have something else that came up:

Is there any way to either:

1) Have 2 grids vertically scroll together as the entries on the 1st one are entered (the 2nd one if info/read only) so the line they are entering on's info/read only record stays on the same line?

2) Have 1 grid and set all of the fields as read only except the 1 field (tracking #) they are entering data for?

Thanks!

Charlie
0
Comment
Question by:cafulford
  • 4
  • 4
  • 2
  • +1
12 Comments
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 167 total points
ID: 33685928
Sync two grid scrollpositions? Not impossible, but it's far easier to work with solution 2: Set all columns to readonly despite the one users should be able to enter tracking # into.

in the Init() method of the grid for example:

This.SetAll("readonly",.T.,"column")
This.ColumnX.ReadOnly = .F.

ColumnX could be Column1 if you redesign the grid or you just add one column and set it's ColumnOrder to 1, while it's name remains some higher column number. You'll find out which column to unset.

Bye, Olaf.
0
 
LVL 12

Expert Comment

by:jrbbldr
ID: 33686025
If there is a 1-to-1 relationship between the records in Grid1's cursor and Grid2's cursor (which would be essential to even consider trying to match the scroll positions) then why use 2 separate grids?    

Why not just use 1 Grid?

Good Luck

0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 33686585
You can have the View property of the second grid to Change so that the columns can be rows and it looks better. What you can do it set a relationship to that file so when you are on a row in the first grid, the second grid would show the all the necessary fields as if they are in a form.

check
SET RELATION TO
oGrid.View
0
 

Author Comment

by:cafulford
ID: 33691898
Ok, changed it to 1 grid and set all the columns except for the 1st one (tracking #) to read only so I am almost there. 2 things:

1) Is there a way to change the color of the read only columns so they can be differentiated from the one the user has to enter data into?

2) is there a way to freeze or keep the grid from scrolling horizontally so that all the 7 fields shown can not move? What I mean by this is if you press the right keys, even though I have disabled the horizontal scrolling, the grid still will move to an unused column and then the 1st column disappears from view.

Thanks!
0
 
LVL 27

Assisted Solution

by:CaptainCyril
CaptainCyril earned 167 total points
ID: 33691948
Columns(n).BackColor changes the backcolor

Columns(n).ForeColor changes the color of the font

Check Scrollbars property to enabled/disable scrollbars
0
 

Author Comment

by:cafulford
ID: 33692186
Where would I put the columns(n), in the init?

Also, I had already disabled the horizontal scrollbars but when you tab, it will tab to the last column, 7th, in this case and show an additional empty column to the right and move all of the columns over 1 to the left so the 1st one disappears from view...
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 27

Expert Comment

by:CaptainCyril
ID: 33692239
I mentioned that I would not put them in columns but rather by rows.

FOR i = 2 TO 5 && Change the backcolor for columns 2 to 5
    oGrid.Columns(i).BackColor = RGB(204,204,204)
ENDFOR
0
 

Author Comment

by:cafulford
ID: 33692414
I'm sorry but I actually do not know what/where you mean. I am very new to VFP. I do not see a row event for the grid. The only thing I see is row height.

Any idea on why it's scrolling horizontally even though horizontal scrollbar if off?
0
 
LVL 12

Assisted Solution

by:jrbbldr
jrbbldr earned 166 total points
ID: 33692618
CaptainCyril is showing you a way to use code to populate the value into all of the indivudal Grid Column's BackColor property.   That code can run in the Form's LOAD method or the INIT method.

His code works on the knowledge that you have set columns 2 through 5 (  FOR i = 2 TO 5  ) as Read Only and those would be set with the different color.

Additionally the same value (  RGB(204,204,204)  ) can manually be put into the Grid's individual Column BackColor property by going into the Form' Grid Property for each individual Column.  If the Grid has few columns I generally do it this way, but if many columns, I use the code approach.

You can also use the Grid Column's DynamicBackColor property in a similar manner to dynamically change the color based on some condition.

Good Luck
0
 

Author Comment

by:cafulford
ID: 33692742
I  see now! I did not realize you could go into individual properties by selecting the drop down of the properties. I did understand what he was doing with the code but just was not sure where to put it. I did try to put it in the forms init event but it said the object could not be found yet the grid name was correct...

Any idea on the the scrolling horizontally?

This is quite a learning experience!
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 33692778
Let's say you have two columns and your grid is called grid2

Thisform.grid2.Columns(2).BackColor = RGB(204,204,204)
Thisform.grid2.Columns(3).BackColor = RGB(204,204,204)

Check the property View inside the Grid properties. Change it's value and see what you get at runtime.
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 33693990
Set the width of the last column so, that you can see the finishing column line additional to the grid outline, then it won't scroll horizontally.

Bye, Olaf.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
What is Backup? Backup software creates one or more copies of the data on your digital devices in case your original data is lost or damaged. Different backup solutions protect different kinds of data and different combinations of devices. For e…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now