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

Editing a cursor – handling dates 1

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
621
GB
I have a modal form which can be used to browse and edit a cursor. So, the name of the cursor and the column captions are passed across; the cursor might contain three fields, quantity, date and comment. After editing the modified cursor is available to the calling form.

This works fine.

I also have a date/textbox class which allows a date to be edited. It has one property, this.zDate which is indeed a date, but the class itself is of base class textbox. It normally displays as ’27-Dec-17’, but when it has focus and is being edited it displays ’27-11-17’, with an input mask of ‘99-99-99’.

I would like to use this control class as a means of editing any of the fields which are dates, using :

Code:
. . .Column1.addobject() . . . .
. . .Column1.curentcontrol = . . .
. . .

but this is not an immediate success , because of the conflicting data types of the field in the cursor and the new control.

Grateful for helpful suggestions. Thanks, Andrew
 
From your description I can only guess how your specific textbox works on strings rather than dates. Well, then you can forget about binding that control the usual way. A class based on textbox still offers the normal controlsource to the grid and the grid makes use of that, overriding all your behaviour and code to act on a zDate string property with the inputmask.

The necessary work to wire this is doable, but now will require you to act on any grid row change not only via AfterRowColChange but also during the rendering of the grid and then within several events like lostfocus and valid. Is it really worth it?
Just the normal date type in conjunction with .DateFormat property offers everything you normally need.

Bye, Olaf.
 
Thanks Olaf

Yes, I was pretty much coming to the same conclusion. I had been putting code (and breakpoints) into the control's gotfocus(), Lostfocus(), Valid() , zDate_assign() events - also into AfterRowColchange(). But was still finding it difficult to stop the cell in the grid from being blanked out.

 
Andrew,

This doesn't answer your question, but remember, if you want to use an input mask with a textbox in a grid, it is the column's InputMask property that must be set, not the textbox's. It might be helpful to keep that in mind.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mainly, you'll need to find another way of the textbox to know the origin of the value and what field to finally update than the grid column controlsource. You'll only get somewhere the grid does not get in your way, if you keep the grid off the textbox controlsource mechanism, as that always means the influence of value and thus also displayvalue.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top