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

How to make a click and rclick event work on specific columns?

Status
Not open for further replies.

lordhawkins

Programmer
Sep 25, 2003
64
0
0
SV
Got a grid that get its columncount property from a fcount() result from a cursor, making this value somewhat random (ranging from 12 to 24).

I need to trigger a click/rclick event on the individual columns in the grid, but just get a response when I aim to a non-used part of the grid. If I touch the data, nothing happens...

How can I set the Click event of every column without recurring to a "col by col" fixing?

 
I believe you'll need to design your column as a CLASS (DEFINE CLASS...ENDDEFINE in a prg) and then use ADDOBJECT to add your column class to the grid as you're building it programatically.

Brian
 
Try this in a prg.

Brian

Code:
LOCAL oForm  
  
CREATE CURSOR temp (CTest C(6), NTest1 N(3), NTest2 N(7,2))  
INSERT INTO temp VALUES ("test1",3,5993.23)  
INSERT INTO temp VALUES ("test2",2,8993.23)  
INSERT INTO temp VALUES ("test3",1,6993.23)  
locate

oForm = CREATEOBJECT('TestForm')  
oForm.Show(1)  

DEFINE CLASS TestForm as Form  
  
ADD OBJECT grdTemp as TestGrid WITH ;  
Left = 5, ;  
Top = 5, ;  
RecordSource = 'temp', ;  
ColumnCount = 3 
  
ENDDEFINE  
  
DEFINE CLASS TestGrid as Grid  
  PROCEDURE Init
   lnCnt=0
   FOR EACH oColumn IN This.Columns
   lnCnt=lnCnt+1
    oColumn.AddObject(FIELD(lnCnt),'ClickMethod')  
   NEXT  
 ENDPROC  
ENDDEFINE  
  
DEFINE CLASS ClickMethod as Header 
  PROCEDURE RIGHTCLICK
    *MESSAGEBOX([right click code here])
     lcSortField=This.caption
     SELECT temp
     INDEX ON &lcSortField ASCENDING TAG a 
     thisform.grdTemp.refresh()
  ENDPROC
  
  PROCEDURE CLICK
     *MESSAGEBOX([left click code here])
     lcSortField=This.caption
     SELECT temp
     INDEX ON &lcSortField DESCENDING TAG a
     thisform.grdTemp.refresh()
  ENDPROC
  
ENDDEFINE
 
Pardon me Baltman, but please tell me whether this code will work on individual row in a column.

What I make out from question is that Lordhawkins wants to trigger the event for individual row.

As for sorting (it is just an example I know), I experimented "SORTING THE GRID ON MULTIPLE COLUMNS". I have explained it in the thread having same title.

Somebody would please tell me how to provide link to a particular thread?

Puru
 
Somebody would please tell me how to provide link to a particular thread?

Just paste the
Code:
 thread184-896976 [code] into your post and it'll look like this thread184-896976.

As to individual column AND row behavior, I think you'd need check the grid's table to see what the active record is and then execute your code using dynamic code based off of the record's values and/or a CASE...ENDCASE.

Another possible alternative would be figuring out where the mouse pointer is and using that as the basis for you logic.

I have no doubt there's someone out there with more experience with thos techniques than myself, so I'll invite them to pick up on the thread.

Brian
 
Thanks for your interest.
Maybe I need to be more specific...!!!
I have a grid with data from a SQL cursor like this:

Machine Timeslot1 Timeslot2 Timeslot3... TimeslotX
Machine1 312 312 312 319
Machine2 315 315 318 0
Machine3 311 313 314 314
Machine4 310 310 310 310

Where the grid represents time usage from a pool of machinery and the number (ie 315) represents a Purchase Order. In the example, it means that PO 315 is going to use time-slot 1 and 2 from machine usage an then the same machine is going to be used for PO 318.
What I want to do is rclick on a CELL and trigger and event to show all the PO details and be able to further modify it). My problem is that the click/rclick don´t trigger with individual cells (NOT COLUMN...!). Should I use a Flexgrid?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top