If you do this every time the user moves into the control it seems to me the 
control's GotFocus method would be the place to do it.

I just threw together a simple form with 2 text boxes on it. The first text box 
I set the format property to D and set the value to date(). In the GotFocus 
event I put this code:

this.SelStart=3
this.SelLength=2

As I tab between the two controls the first control behaves as you described 
the day portion of my textbox is selected. Of course this assumes MDY for the 
date format. If you only want it to happen the first time the user enters the 
control, you would need to some kind of flag to indicate that first time and 
flip it as needed,

--
rk

-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Gene 
Wirchenko
Sent: Thursday, May 16, 2013 3:05 PM
To: [email protected]
Subject: Nasty Problem with Activate

Dear Vixens and Reynards:

      I am doing some clean-up of forms.  On one form's date control, on entry 
to the field, the cursor should be set to just before the day part of the date. 
 I was previously doing this with the keyboard command.

      I had tried .selstart and .sellength, but it did not work.  It turns out 
that .gotfocus is the wrong event for it.  It is .activate that you have to put 
the selection code in.

      This worked fine in tests.

      Unfortunately, in the form, this is the first control.  For some reason, 
it does not work.  If I swap the first two controls, then it does work.  This 
will not be acceptable for the production app though.

      The .activate code does execute, but it does not select.  Instead, the 
cursor is positioned at the beginning of the field.

      How do I get .selstart and .sellength to work right?

      I suppose it could be something in my form framework code, but I have 
been wrestling with this this morning, and if it is a VFP quirk instead one of 
my code, I would waste a lot of time for nothing.

      I do .setfocus() to the first control that can accept input.  Surely this 
means that .activate will fire and execute correctly?

      Any help would be greatly appreciated.

Sincerely,

Gene Wirchenko


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/DF1EEF11E586A64FB54A97F22A8BD044227E66E8A9@ACKBWDDQH1.artfact.local
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to