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

Procedures in grid

Status
Not open for further replies.

Bryan - Gendev

Programmer
Jan 9, 2011
408
AU
I am using Ramani's grid class in my prg files to create grids. I have other classes to respond to mouse clicks in a particular column.

I can only use one class definition for a column so my question is - can I have more than one procedure in a class as below?

An example for one column below

<code>

With .Column10
.ControlSource = 'EDITING_.NEWPATH'
.Header1.Caption= 'NewPath'
.AddObject("mycmd","gs_newpath")<<<<<<<<<<<<
.Sparse = .F.
.CurrentControl = "mycmd"
.ReadOnly = .F.
.Width = 60
Endwith

Define Class gs_newpath As TextBox <<<<<<<<<<<

Procedure DblClick

... some work here

endproc

Procedure Click

... some work here

endproc

enddefine

</code>

Thanks in anticipation

GenDev
 
Not sure what you mean by "more than one procedure".

If you want the column to contain both the existing textbox and your new command button, that's perfectly possible. In fact, you've already got that.

If you want to add code to the command button, you can do it in exactly the same way as you did for the textbox.

If this doesn't cover it, please explain exactly what your question is.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
You can have as many procedures (or methods) in a class as you like, what's your problem?

Bye, Olaf.
 
Mike and Olaf,
Thanks for your interest. I thought I explained my question. I want to allow click or dblclick on a textbox field in my grid. It didn't seem to work when I put some test code in but it seems it should so I'll try again.

regards
'
GenDev
 
If a click (or dblclick) event occurs for a control in a grid column depends on allowcellselection, I think. It's worth trying to set this .t., if it was .f.

Bye, Olaf.
 
GenDev,

Based on the code that you posted, a click or double-click on the textbox won't fire because it's not the "current control". You have added a command button to the grid, and set that as the current control (I'm assuming "MyCmd" is a command button) so it is that control that is receiving the events.

In fact, I'm surprised you can even see the textbox, let alone click on it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Ok, so the answer to my question is that the code I posted won't work.

So now I've tried to satisfy my user with another fiddle. I've added a new column as the prg runs and fill it with the old value - then I test the contents later to see if it has been edited.

So I'll stick with that and leave the "MyCmd" button as it was with a 'Click' event only.

Thanks

GenDev
 
GenDev, if adding the new column solved the original problem, that's fine. But you said it was a "fiddle". If it does not provide the ideal solution, perhaps you could explain exactly what you are trying to achieve. Maybe then we can help you find the solution you need.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Mike, while the control instance is named mycmd it actually is a textbox, everything was fine with gendevs code.

.AddObject("mycmd","gs_newpath")

adds mycmd as an instance of gs_newpath
and gs_newpath is a textbox class defined by
Define Class gs_newpath As TextBox

He also set's sparse .f. and makes it the current control.

The question simply is what errors occur, and if no errors occur at all, what suppresses the events.

Bye, Olaf.
 
For example, do you set the recordsource later after modifying the column10 this way? Then you may have lost the new control, as that resets the grid.

Bye, Olaf.
 
Well, or do you put DEFINE CLASS into a rid method? That doesn't work. DEFINE CLASS must always be in a seperate PRG, you need to SET PROCEDURE TO it (ADDITIVE) and then can use the AddObject() method.

Bye, Olaf.
 
Thanks Mike and Olaf,

My American user got the new exe this morning and is very satisfied with the added column solution, so my 'fiddle' works fine and I will leave it as the method in my app.

Ramanis grids work fine for me - I can do anything I want in the cells via the "myCmd" technique with new classes outside the main class.

Regards

GenDev
 
I still don't know what FAQ of ramani you reference, but DEFINE CLASS is actually something I tend to avoid, if there are visual classes available you can also use, as they give more visual control, and need less coding to specify visual properties like position ans size.

And vcx classes are easier to subclass in my oppinion, especially if you don't just inherit within the VCX, but VCXes to separate different inheritance levels of eg framework class, general application class, sepcialised class for a certain customer or for a certain application.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top