usercontrol-classes
usercontrol-classes
(OP)
hi all
iam developing a usercontrol, with 9 command buttons for next,previous,first,last,save,edit,del,find,exit......
i have written a general codeing as mentioned below in usercontrol command button.
but my problem is when i use to add it in form and click the button for move next, the code in the class file never fires,only the code which is at form.usercontrol.next.click event fires...., immeditate replies will be helpful
under usercontrol.class file
code for next button
skip 1
do case
case eof()=.t.
go bott
wait wind "eof reached"
endcase
wait wind "clicked" nowait
under form =>usercontrol.next.click event
thisform.text1.value=fieldname (field name of current DB)
cheers
parthi
iam developing a usercontrol, with 9 command buttons for next,previous,first,last,save,edit,del,find,exit......
i have written a general codeing as mentioned below in usercontrol command button.
but my problem is when i use to add it in form and click the button for move next, the code in the class file never fires,only the code which is at form.usercontrol.next.click event fires...., immeditate replies will be helpful
under usercontrol.class file
code for next button
skip 1
do case
case eof()=.t.
go bott
wait wind "eof reached"
endcase
wait wind "clicked" nowait
under form =>usercontrol.next.click event
thisform.text1.value=fieldname (field name of current DB)
cheers
parthi
RE: usercontrol-classes
Remember: any code, space or comment in the subclass will prevent the baseclasscode to fire if you do not add a DODEFAULT().
>under form =>usercontrol.next.click event
>thisform.text1.value=fieldname (field name of current DB)
Why don't you bind the field of the table to the textbox control (controlsource) and issue a refresh.
In that case, you won't have to put any code in your subclassed control.
Your code would be something like:
PROCEDURE usercontrol.next.click
*- code for next button
LOCAL lnSelect, lcAlias
lnSelect = SELECT()
*- The alias could be stored as a property of your form
lcAlias = THISFORM.cTable && select the table
SELECT &lcAlias
IF EOF(lcAlias)
GO BOTTOM
ELSE
SKIP 1 IN &lcAlias
IF EOF(lcAlias)
GO BOTTOM
ENDIF
ENDIF
SELECT (lnSelect)
THISFORM.REFRESH()
ENDPROC
HTH,
Weedz (Wietze Veld)
My private project:www.crowncap.demon.nl\info\crwnbase
Download the CrownBase source code !!
RE: usercontrol-classes
For some good advice on this subject see:
http://fox.wikis.com/wc.dll?Wiki~UserInterfaceLayer
http://fox.wikis.com/wc.dll?Wiki~EventsShouldAlwaysCallMethods
HTH,
Weedz (Wietze Veld)
My private project:www.crowncap.demon.nl\info\crwnbase
Download the CrownBase source code !!
RE: usercontrol-classes
but i cant understand the above explanation, can you just able to explaing me in detail as if iam new to VFP class and user controls.. please...
thanks
parthi
RE: usercontrol-classes
PROCEDURE usercontrol.next.click
*- code for next button
LOCAL lnSelect, lcAlias
lnSelect = SELECT()
*- The alias could be stored as a property of your form
lcAlias = THISFORM.cTable && select the table
SELECT &lcAlias
IF EOF(lcAlias)
GO BOTTOM
ELSE
SKIP 1 IN &lcAlias
IF EOF(lcAlias)
GO BOTTOM
ENDIF
ENDIF
SELECT (lnSelect)
THISFORM.REFRESH()
ENDPROC
HTH,
i cant understand the code , please explain me to where to put the above code ...
cheers
parthi
RE: usercontrol-classes
2. Go to the menu option: Class/Edit property/method
3. Choose: new property
4. enter: cAlias
5. Choose: new method
6. enter: next
7. Choose close and save changes
8. Open the properties sheet of the user control
9. Choose the method: next and doubleclick
And put in the following code:
LOCAL lnSelect, lcAlias
lnSelect = SELECT()
lcAlias = THIS.cAlias && select the table
SELECT &lcAlias
IF EOF(lcAlias)
GO BOTTOM
ELSE
SKIP 1 IN &lcAlias
IF EOF(lcAlias)
GO BOTTOM
ENDIF
ENDIF
SELECT (lnSelect)
THISFORM.REFRESH()
10. Put in the click event of your next button the following code:
LOCAL llRetVal
llRetVal = DODEFAULT()
IF llRetVal
THIS.PARENT.Next()
ENDIF
RETURN llRetVal
11. Put the control on your form.
12. Fill in for the property cAlias of your user control the name of the table through which you wish to navigate.
Et voilĂ , it should work.
Same goes for navigation to the previous record, the first and the last record.
HTH,
Weedz (Wietze Veld)
My private project:www.crowncap.demon.nl\info\crwnbase
Download the CrownBase source code !!