Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Setfocus() in grid column
Message
 
To
29/06/2001 00:16:18
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00525000
Message ID:
00525034
Views:
18
This message has been marked as the solution to the initial question of the thread.
>>Hi Budianto,
>>
>>I not sure what you mean. If you have a grid with only 4 columns visible, and you are on 5th (first 4 are not in sight) the code in the button
>>
>>this.parent.grid1.column3.setfocus()
>>
>>just automatically scrolls the grid back and sets the focus to the third column. Could you post the code in your button.Click() ?
>
>Hi Nick,
>
>Thanks for the reply, actually, all of the columns are visible, it's just that if I'm on the 5th to 8th column and I click the add button, the pointer is always go to the first column. This does not happend if I'm on the 1st to 4th column.
>Here is my add button code :
>
>thisform.grid1.Column3.readonly=.f.
>thisform.grid1.Column4.readonly=.f.
>thisform.grid1.Column5.readonly=.f.
>thisform.grid1.Column6.readonly=.f.
>thisform.grid1.Column7.readonly=.f.
>thisform.grid1.Column8.readonly=.f.
>sele MyTempGridFile
>appe blank
>thisform.grid1.refresh()
>thisform.grid1.column3.setfocus()
>
>For your information the 1st and 2nd column is enabled=.f. because I don't want the user to edit this column, so it should jump to the 3rd column.

That can happen if you moved the columns in your grid around. Check what is the name of the column which really gets focus. See the sample form I just sent you where everything works as you want it, and check what is different from yours.

Also, you might want to use WITH ... ENDWITH to simplify and speed up your code:

WITH thisform.grid1
.Column3.readonly=.f.
.Column4.readonly=.f.
.Column5.readonly=.f.
.Column6.readonly=.f.
.Column7.readonly=.f.
.Column8.readonly=.f.
sele MyTempGridFile
appe blank
.refresh()
.column3.setfocus()
ENDWITH


Or use SetAll method:

WITH thisform.grid1
.SetAll("ReadOnly", .f., "Column") && Column 1 and 2 have .Enabled = .f. so their .ReadOnly setting does not really matter
sele MyTempGridFile
appe blank
.refresh()
.column3.setfocus()
ENDWITH
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform