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





 
HI

You can put the code.. in the init event of the Grid..

This.RecordSource=""

Hope this helps you :)
ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
In the Grid class, set the RecordSource EXPLICITLY to (None) by putting something in it then deleting it. You can tell the difference because (None) will be in bold.

This may sound dumb, but it will tell VFP not to load anything and the grid will remain empty.

Ian
 
Hi Everyone,
thanks for your response.
Ramani: I include
This.RecordSource="" on the init event of the Grid class but I didn't work I can see that headers are still loaded.

Ian: I also tried your suggestion by putting something in it then deleting it, but it didn't work either.

Any other ideas will be apreciated.

Thanks

 
Do you really need to add the grid programmatically? Why not drop the Grid onto the form at design time?

(NOTE: this will only work if you are using a Visual Class library. If your class is defined in a PRG file, this won't work.)

To do this, you will need to add your grid's Visual Class Library to your Controls toolbar. Go to the Tools menu, select Options, click on the Controls tab, and select the Visual Class Libararies radio button. Click the Add... command button and add your library, then click Ok. Then go to your toolbar, click the View Classes button (looks like a row of books with a tiny downward arrow) and select your class library from it.

Ian
 
Hi Ian,
2 things:
-I was able to include the libary that contains the grid
I and tried to drop the into the form but it's asking that a form set object is required. How is it differen form a regular form?
I already have other controls in form.

- How do I put back the other controls, When I go to view,
form controls tool bar I just see my lib that I just included

Thanks.
 
The normal controls are ALWAYS there. You don't need to set anything in your Options...just click the button with the books on it and select "Standard".

It sounds like the class you tried to drop in was a Form, not a Grid. Make sure you are trying to drop the right control. :eek:)

Ian
 
Ian,
this libray contains 2 forms
One is a base form and the other is form based on the previous one. Does it have to do somenthing with it?


And I konw how to see the controls now.

thanks
 
Ian,
Never mind I was lncluding a wrong lib.

Thanks Again

Guillermo
 
Ian,
I place code in the init and aftercolchange events of the grid class.
After dropping the grid into the form, the code in the parent class is no being executed:

Init Event:
DODEFAULT()
this.RecordSource = ""
go bottom
This.SetAll("DynamicBackColor", ;
"IIF(recno(This.RecordSource)=THISFORM.nRecord, ;
RGB(128,255,255),RGB(255,255,192))","COLUMN")
this.refresh()

Afterrowcolchange Event:
LPARAMETERS nColIndex
ThisForm.nRecord = RECNO()
this.refresh()

Am I missing something?

Thanks
 
The code in which parent class? Exactly what isn't being executed?

FYI, there is no reason to execute "this.refresh()" in the INIT event...it occurs before the form is even visible. There is an implicit REFRESH() called after all INIT() events are processed.

I would also get rid of the "this.refresh()" in the AfterRowColChange event. It could cause problems and you are making no changes that need to be refreshed.

Ian
 
Ian,
The code in which parent class?
The Grid class called "MyGrid".

Exactly what isn't being executed?
I take that back, I was debugging and I realized that the code in both eventes are being executed.

But they are not behaving like expected. I am trying to change the color of grid: yellow and cyan(current record)
the grid is black and white.

Do you see where am I making the mistake?

Thanks


 
Try this instead:
[tt]
This.SetAll("DynamicBackColor", ;
"IIF(recno()=THISFORM.nRecord, ;
RGB(128,255,255),RGB(255,255,192))","COLUMN")
[/tt]
Ian
 
I'm assuming you're using Ramani's faq184-1264 about grid highlighting since your code looks very similar. I can't imagine why it doesn't work for you. I remember trying it long ago and it worked fine for me, although my end users thought it was too slow and made me take it out. :eek:/

What exactly is it doing?

Ian
 
Ian,
If create a regular grid at design time. And the grid property recordsource is a table it works fine.

But Now I have a Visual Grid class "Mygrid"
recordsourcetype = 4 SQL
recordsource = Select statement (run time)

This is the only difference




 
When you are using an SQL statement as the RecordSource, you CANNOT use "RECNO(This.RecordSource)". You must use the cursor name specified in your SQL statement. So change your command to this:
[tt]
This.SetAll("DynamicBackColor", ;
"IIF(recno('MyCursor')=THISFORM.nRecord, ;
RGB(128,255,255),RGB(255,255,192))","COLUMN")
[/tt]
Substitute the name you specified in the INTO CURSOR clause of your SQL statement in place of MyCursor.

Ian
 
I advise you to use ActiveX Grid version 1.1 from DBi tech
it's very useful all you can do with it

If you have some problems with this grid let me know.
 
Ian,
Didn't work.
-I place the explictly the name of the cursor C_INVOICE in the init event of the grid class.
-I tryed use the init and afterRowColChange code straight in the grid on my form didn't work either.
-I put a breakpint here just to make sure this piece of code is being executed. I even a place a wrong cursor name but it didn't complaint

This.SetAll("DynamicBackColor", ;
"IIF(recno('C_INVOICE')=THISFORM.nRecord, ;
RGB(128,255,255),RGB(255,255,192))","COLUMN")

Where can get the other grid from DBi Tech?
 
Make sure you have the SETALL statement executing AFTER the line that sets the grid's RECORDSOURCE.

Other than that, I'm out of ideas. :eek:(

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top