Solved

Another VFP 6 grid question

Posted on 2010-09-15
12
967 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Fox9 and Windows 8 4 2,945
Mysql Search for contact 6 235
convert/ import XLSB / vfp9 5 74
How to obtain VFP OLEDB string connection to use in code? 16 99
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…
Facing problems with you memory card? Cannot access your memory card? All stored data, images, videos are lost? If these are your questions...than this small article might help you out in retrieving your lost or inaccessible data.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

937 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

5 Experts available now in Live!

Get 1:1 Help Now