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

Using Hierarchical Flexgrid 1

Status
Not open for further replies.

lordhawkins

Programmer
Sep 25, 2003
64
SV
I need to use a Hierarchical Flexgrid (the ActiveX that comes with VFP7) because i need to be able to select multiple cell for fill them with data.
[ul]How can I populate the grid? I've tried:
Code:
SELECT * from rollos WHERE procesado=1 INTO CURSOR gaga
thisform.Grid1.r.Recordset = "gaga"
but got the message Ole error Unknown member[/ul]

Do I need to send an AddObject command to the form, creating the grid on the fly?

If that is so, what's the name of the classes to use? I've tried this:

Code:
thisform.AddObject("grid2","Olecontrol","MSHierarchicalFlexGridLib.MSH")
but the class name is not right[/code]

Lastly. It's possible to use the normal grid from VFP to select multiple cells? If that is so, how?
 
when using activex controls you need to use ADO. Below is the code I used in a MSHFLEXGRID (active x) which allows you to use shaped recordsets (they are like 2 cursors in foxpro with a relation set). If you don't understand ADO then you may have to learn about it first. You will find that you have to use ADO when working with any controls outside of the foxpro controls. The world outside of foxpro uses ado for recordsets. Only in foxpro will you set a recordset to a foxpro cursor. For this reason it is far easier to accomplish your tasks within the foxpro control. You may be able to accomplish what you want with a standard foxpro grid as a thought. I have beat this topic myself trying to weigh out using odd programming just so I can use a foxpro grid or using ado with activex controls which is more complicated.

This I put into the init of the control:

PUBLIC oConn1, oRstP1, oRstC1, oRstC2
oConn1=CREATEOBJECT("ADODB.Connection")

oRstP1=CREATEOBJECT("ADODB.Recordset")


oConn1.Provider = "MSDataShape"
oConn1.Open("Provider=MSDataShape;Data Provider=MSDASQL;Server=1.1.1.1;Data Source=Maps;User ID=sa;Password=unknown")

oRstP1.StayInSync = .T.
oRstP1.Open("SHAPE {select Item_id, effort from maps.dbo.effort_only} AS Item_Effort" +;
"APPEND ({select offer_code, Landed_cost, item_id from maps.dbo.Item_Offer} " +;
"RELATE Item_id TO Item_id) AS Items", oConn1)
ThisForm.olecontrol1.recordset=oRstP1

Regards,

Rob
 
But I'm using the data directly from a VFP's DBC.
Could I use the cursor as the recordset?
Could I use an object created from the data from a query?
 
You asked: Could I use the cursor as the recordset?
Answer: NO
You asked: Could I use an object created from the data from a query?
Answer: If the object is an ADO recordset, yes.

Since your data is in Foxpro data tables inside a DBC you would simply create an ADO recorset from these foxpro tables. Then you would set the recordset of the activex grid to this foxpro ado recordset. Have you already determined that you cannot use the native foxpro grid for your task? It is by far more difficult to work with activex grids of any type compared to the native foxpro grid.

Regards,

Rob
 
First thing first.
Thanks for the advice. The solution works...!!! [2thumbsup]

What I want to do is (simply stated):
1-Load the cursor/recordset that contains: Invoice,Barcode,Color,Shipment, plus an empty column for the Code.
2-Select the color code from another list.
3-Select a range of cells in the Code column.
4- And insert (copy or otherwise) the color code in the empty cell.

Is this possible with the VFP (7.0 o 8.0) native grid?
I couldn't do it, that's why I've recurred to a Flexgrid.
 
1st pull all the data into one cursor and correctly group and order it, appending your blank code as int assume.

2nd - user will select the color from dropdown or listbox.

3rd - I assume you are wanting to muli-select rows on the grid which is set to the RecordSource = to the cursor from step 1? If so yes you can read on how to muliselect on grids from faq184-433 you can also use listboxes for multi select.

4th - Once you have the method from step 3 worked out you would simply take the cursor returned from the query of selected rows and use it to update the records in the 1st step with the selected code.

Regards,

Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top