Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting a grid display

Status
Not open for further replies.

shenlon

Programmer
Jul 9, 2003
47
US
OK, here's what I have: I have a grid that displays the information from a database. Users cannot modify the database in any form from this grid, it is to view information only. I want to make it so that when the user clicks on a cell within the grid that whole row is highlighted, not just the cell. I also want the user to be able to double click on any record and it take them to another form, but I'm 99% sure I already know how to do that. Thanks in advance.
 
Thanks a bunch, new it couldn't be something all to difficult, just an option I was overlooking somewhere.
 
Wait, I went back and looked for that property, and I can't seem to find it. I should also probably mention that I'm using VFP 6.0, as I foolishly forgot in my first post.
 
Shelnon,

I am sorry, thats' available with VFP8!

Foxbldr

 
HI
1. How to hilight the current row (VFP6 or VFP7).. Look in this FAQ..
How to make grid display current row in distinct color?
faq184-1264

2. You have to put in the double click event of every TextBox or control of each column .. DO FORM myEditForm
to enable a myEditForm to take control and do the editing of the current record. I would suggest make that a modal form.

:)


ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
I tried both methods that you listed in your FAQ and unfortunately could not get either to work correctly :(. The first one I tried:
MyGrid.InitEvent
****************
DODEFAULT()
WITH THIS
.SetAll("DynamicBackColor", ;
"IIF(recno(This.RecordSource)=ThisForm.inRecno, ;
RGB(0,255,255),RGB(255,255,192))","COLUMN")
ENDWITH

MyGrid.AfterRowColChangeEvent
*****************************
DODEFAULT()
ThisForm.inRecNo = RECNO()
This.Columns(This.ActiveColumn).Text1.BackColor = RGB(0,255,255)
This.Refresh()

Gives me an "Expression is invalid. Use a valid expression for DYNAMICBACKCOLOR property." I tried changing it to just BackColor such as it is in the Properties window, but I was then informed that the data type was invalid for that property. So, I deleted all that code, and loaded the other example you had:
MyGrid.InitEvent
****************
DODEFAULT()
WITH THIS
.SetAll("DynamicBackColor", ;
"IIF(recno(This.RecordSource)=ThisForm.inRecno, ;
RGB(0,255,255),RGB(255,255,192))","COLUMN")
ENDWITH
nColumncount=This.ColumnCount
For I=1 To nColumncount
Objref=Eval('this.columns(i).'+ ;
This.column1.CurrentControl)
Objref.BackColor=RGB(0,255,255)
Objref.SelectedBackColor=RGB(0,255,255)
Objref.SelectedForecolor = RGB(0,0,0)
Endfor
When trying to run this example, the same errors occur, first I get the message that DynamicBackColor is an invalid expression, and if I change it to BackColor then the data type becomes invalid. The 2nd method DOES however change the specific cell that you click on to the color. Please help :((
 
shenlon,

You have to add "inRecno" property to your FORM.

-- AirCon --
 
Hi
Copy the code and try your test run.. from the FAQ

A sample Search Form.
faq184-2858

:)


ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
Ramani, I want to say thank you so much for the help that you have given me so far, I've learned a lot, but unfortunately something still isn't working right. I got all the other kinks worked out, but when I run my form, I get a "Property INRECNO is not found error." I thought that by putting a line of code saying inRecno=0 in the Load portion of my form's code that it would clear things up, but apparently not. What am I missing??
 
shenlon

The code in the FAQ assumes that you are adding a property to the form not declaring a variable.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Shenlon

I hope this helps. Put this code in the Grids Refresh event

Code:
LOCAL lnRecord
lnRecord=RECNO()  &&or RECNO("TableName")
 
this..SetAll("DynamicBackColor", "IIF(RECNO()="+allt(str(lnRecord))+", RGB(255,255,192), RGB(255,255,255))", "Column")

You can store the record number as a property of the form if you wish to, in which case just set lnRecord as follows
Code:
lnRecord=THISFORM.nRecord  &&nRecord is the Property Name



WTrueman
...if it works dont mess with it
 
Thanks for the suggestion W, I'll play around with that some, maybe it will help.

Mike - The code in the first FAQ says "At the form level create a variable,say, inRecNo and put the initial value as 0 ." I'm not trying to be an ass or anything, I am new to the language and if that meant that I was supposed to add it as a property, then I will know that from now on, but as I read it i took it as to declare a variable. If otherwise, can someone show me how to add the property? I appreciate your help and your patience, I really do. Thanks a bunch.
 
Shenlon

If you want to add a property to a form.
modi form <myformname>

Then from the Form Menu, simply select New property. If you add a property namedy nGridRecno, you then reference it in code as follows. You can then find the property on the form properties toolbar, and set it to an initial value of say zero. The default property value is a logical False.

Code:
LOCAL lnRecord
lnRecord = THISFORM.nGridRecno  &&get
THISFORM.nGridrECNO = lnRecord &&set




WTrueman
...if it works dont mess with it
 
Thanks W, that helped a lot, but now I get a message saying &quot;Variable COLUMN is not found.&quot; As a refresher, here's my current code:

DODEFAULT()
WITH THIS
.SetAll(THIS.BackColor, ;
IIF(recno(This.RecordSource)==ThisForm.inRecno, ;
RGB(0,255,255),RGB(255,255,192)),COLUMN)
ENDWITH
nColumncount=This.ColumnCount
For I=1 To nColumncount
Objref=Eval('this.columns(i).'+ ;
This.column1.CurrentControl)
Objref.BackColor=RGB(0,255,255)
Objref.SelectedBackColor=RGB(0,255,255)
Objref.SelectedForecolor = RGB(0,0,0)
Endfor
 
Shenlon

Simply enclose the word COLUMN in Quotes.... &quot;COLUMN&quot;

WTrueman
...if it works dont mess with it
 
shenlon

I'm not trying to be an ass or anything, I am new to the language and if that meant that I was supposed to add it as a property,

Sorry wrong faq, I was refering to faq184-2858.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Not a problem Mike, just making sure I was understanding the situation correctly.

W- If I enclose the COLUMN in quotes, I get a function argument, value, or type error message. Do you understand why? Can someone clue me in?
 
Actually, all the parameters need to be in quotes, but you need to change &quot;THIS.BackColor&quot; to &quot;dynamicbackcolor&quot;, or it will only change the current cell of the current record as the grid is being initialized:

.SetAll(&quot;dynamicbackcolor&quot;, ;
&quot;IIF(recno(This.RecordSource)==ThisForm.inRecno, ;
RGB(0,255,255),RGB(255,255,192))&quot;,&quot;COLUMN&quot;)

You may also want to check out my FAQ:
How do I change grids' row/column colors/fonts, ...
faq184-3098


-Dave S.-
[cheers]
Even more Fox stuff at:
 
Shenlon
Im assuming you now have 2 properties on your form as follows
1) RecordSource = character name of table
2) inRecno = current record number of above table

In the Refresh event of the grid paste the following code
Code:
this.SetAll(&quot;DynamicBackColor&quot;, &quot;IIF(RECNO(THISFORM.RecordSource)=&quot;+allt(str(thisform.inrecno))+&quot;, RGB(255,255,192), RGB(255,255,255))&quot;, &quot;Column&quot;)
dodefault()

In the AfterRowColChange event, put the following code
Code:
thisform.inrecno=recno()
this.refresh

You have to use dynamicbackcolor, and the IIF statement has to be built as a string.



WTrueman
...if it works dont mess with it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top