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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Grid class and tables

Status
Not open for further replies.

guillermo88

Programmer
Jun 1, 2001
55
0
0
US
Help with Grid class and tables

-I have a grid class, mygrid.
-I using addobject("oGrid","myGrid") in the load event of the form

Problem was that grid was being loaded with info of the first table
in DE.
I fixed this by adding the following in the init event of the DE:
thisform.oGrid.recordSource=""

BUT still loads the headers of the grid with info of the table.

Before I had a grid created at design time within the form and placing:
thisform.oGrid.recordSource="" in the init event of DE the problem
of loading the table was fixed

But I want to use this generic grid so I can reuse in different
forms.

How can fix this unwanted behavior?

Thanks





 
Ian,
I don't understand when you say SETALL statement,
myGrid.setAll?
 
I was just looking at your code again...
[tt]
this.RecordSource = ""
go bottom
This.SetAll("DynamicBackColor", ;
"IIF(recno(This.RecordSource)=THISFORM.nRecord, ;
RGB(128,255,255),RGB(255,255,192))","COLUMN")
this.refresh()
[/tt]
Notice the part I put in RED.

This is what leads me to believe that your This.SetAll code is executing BEFORE you are setting your RecordSource to the SQL statement. I'm pretty sure that won't work. After you set the SQL statement, THEN set the DynamicBackColor properties.

Ian
 
Ian,
this.RecordSource = "" AND
go bottom

they were removed before since I have it in the init event of DE.
But you are right the cursor does not exist when init event it's executed.
So what your are saying is to create a new method with grid class and call that method right after setting grid.recordsource?
 
Ian,

I createed a method called setColor and a property tableName in the parent class.

Within my form set mygrid.TableName = "C_INVOICE"
Then set myGrid.RecordSource = SQLvariable
Then call myGridRecordSource.SetColor

wich is the follow:

SELECT (this.tablename)
This.SetAll("DynamicBackColor1", ;
"IIF(recno(this.tableName)=THISFORM.nRecord, ;
RGB(128,255,255),RGB(255,255,192))","COLUMN")

But still does not work

I put a breakpoint after the SELECT (this.tablename)
I tried to do this
?used(this.tableName)
and I got expression could not be evaluated...
Same thing with this:
?used('C_INVOICE')
I tried Alias()
And I saw 'C_INVOICE'
So I change
"IIF(recno(Alias())=THISFORM.nRecord, ;

No Luck

 
Did you copy/paste this code directly? If so...this might be your problem:
[tt]
This.SetAll("DynamicBackColor1", ;
[/tt]
It should be DynamicBackColor, NOT DynamicBackColor1.

Ian
 
Ian,
that was it! It's working.
I forgot to remove "1". I did this expectng an error but nothing happen before.

Now I can resuse this grid class to browse Cursor. And I guess I have to invoke the method setColor only once.

Thanks Again
 
Ian,
that was it! It's working.
I forgot to remove "1". I did this expectng an error but nothing happen before.

Now I can resuse this grid class to browse Cursor. And I guess I have to invoke the method setColor only once.

I dont konw Why it dosnt work using this.tableName instead of Alias()
When I use :this.tableName I got this error
Ecpresion is invalid.Use a valid expression for DYNAMICBACKCOLOR property.

"IIF(recno(Alias())=THISFORM.nRecord, ;
RGB(128,255,255),RGB(255,255,192))","COLUMN")

Thanks Again
 
You'll get this error if using the expression by itself would generate a Visual FoxPro error. My guess as to your specific problem there is that "This.Tablename" doesn't always evaluate to a character field. As soon as it doesn't, the expression will crash.

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top