Tab Order
Tab Order
Hello,can any one help me
How can i Set the tab order of control by code.iam not using Resource for designing .
Regards,
sajith
How can i Set the tab order of control by code.iam not using Resource for designing .
Regards,
sajith
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Tab Order
Sajith,
The focus will be set by the order that you use to create the controls, i.e.:
Now, to reverse that focus sequence, we first create the second GET:
The focus will be set by the order that you use to create the controls, i.e.:
Code: Select all
#include "FiveWin.ch"
function Main()
local oDlg, cFirst := Space( 20 ), cLast := Space( 20 )
DEFINE DIALOG oDlg TITLE "Test"
@ 1, 1 GET cFirst
@ 2, 1 GET cLast
ACTIVATE DIALOG oDlg CENTERED
return nil
Code: Select all
#include "FiveWin.ch"
function Main()
local oDlg, cFirst := Space( 20 ), cLast := Space( 20 )
DEFINE DIALOG oDlg TITLE "Test"
@ 2, 1 GET cLast
@ 1, 1 GET cFirst
ACTIVATE DIALOG oDlg CENTERED
return nil
Re: Tab Order
many many thanks for ur support,
My pblm is for example :
in the above code i added 3rd contol in the last line i want to set the Tab position of that control to 3. how it is possible
Regards,
sajith
My pblm is for example :
Code: Select all
#include "FiveWin.ch"
function Main()
local oDlg, cFirst := Space( 20 ), cLast := Space( 20 )
DEFINE DIALOG oDlg TITLE "Test"
@ 1, 1 GET cLast
@ 2, 1 GET cFirst
@ 4, 1 GET cFirst
@ 5, 1 GET cFirst
@ 6, 1 GET cFirst
@ 7, 1 GET cFirst
@ 8, 1 GET cFirst
@ 3, 1 GET cFirst //3 rd control
ACTIVATE DIALOG oDlg CENTERED
return nil
Regards,
sajith
Re: Tab Order
Dear Mr.Sajith,
If you want oGet6 to receive the first focus then you should define oGet6 first, then oGet1, oGet2, oGet3 etc.
Hope it is clear to you.
Regards
Anser
That is what Mr.Antonio has explained. TAB order will work as per the order in which the control is defined/created in your PRG. While coding you have to decide and then write the code accordingly.in the above code i added 3rd contol in the last line i want to set the Tab position of that control to 3 . how it is possible
Code: Select all
#include "FiveWin.ch"
function Main()
local oDlg, cFirst := Space( 20 ), cLast := Space( 20 )
Local oGet1, oGet2, oGet3, oGet4, oGet5, oGet6, oGet7, oGet8
Local cVar1, cVar2, cVar3, cVar4, cVar5, cVar6, cVar7, cVar8
DEFINE DIALOG oDlg TITLE "Test"
@ 1, 1 GET oGet1 VAR cGet1
@ 2, 1 GET oGet2 VAR cGet2
@ 3, 1 GET oGet3 VAR cGet3 //3 rd control , moved from last line
@ 4, 1 GET oGet4 VAR cGet4
@ 5, 1 GET oGet5 VAR cGet5
@ 6, 1 GET oGet6 VAR cGet6
@ 7, 1 GET oGet7 VAR cGet7
@ 8, 1 GET oGet8 VAR cGet8
ACTIVATE DIALOG oDlg CENTERED
return nil
Code: Select all
@ 6, 1 GET oGet6 VAR cGet6
@ 1, 1 GET oGet1 VAR cGet1
@ 2, 1 GET oGet2 VAR cGet2
Regards
Anser
Re: Tab Order
many thanks for ur reply,
Regards,
sajith
it will be very difficult and time consuming if we need to alter the structure of Design after all coding is finished .TAB order will work as per the order in which the control is defined/created in your PRG. While coding you have to decide and then write the code accordingly.
Regards,
sajith
Re: Tab Order
Dear Mr.Sajith,
For eg. see how I changed the tab order based on the example which I posted earlier. The Get objects TAB order changed from 6,1,2 to 2,6, 1
Regards
Anser
It is just a matter of moving the Get declaration statement in the prg 1 or 2 line above or below. I don't think it is that difficult.it will be very difficult and time consuming if we need to alter the structure after all coding is finished
For eg. see how I changed the tab order based on the example which I posted earlier. The Get objects TAB order changed from 6,1,2 to 2,6, 1
Code: Select all
@ 2, 1 GET oGet2 VAR cGet2
@ 6, 1 GET oGet6 VAR cGet6
@ 1, 1 GET oGet1 VAR cGet1
Anser
Last edited by anserkk on Sat Sep 19, 2009 9:49 am, edited 1 time in total.
Re: Tab Order
Many thanks for ur support,
Suppose if i add a new control in 24 th position i need to alter position of all control.
Hope u got me
Regards,
sajith
Pls view the below Function ::It is just a matter of moving the Get declaration statement in the prg 1 or 2 line above or below. I don't think it is that difficult.
Suppose if i add a new control in 24 th position i need to alter position of all control.
Hope u got me
Code: Select all
//------------------------------------------------------------------------------
FUNCTION ClearTextEmpPaySlipData(oDlg) //For Clearing All the Controls In the Dialog
//------------------------------------------------------------------------------
LOCAL oTxtTotalSalary,oTxtPfAmt,oTxtTaxAmt,oTxtLOPAmt,;
oTxtInsAmt,oTxtOtherDeduction, oTxtTAAmt,;
oTxtOtherAdditions,oTxtName ,oTxtBranch,;
oTxtDepartment,oTxtBasicSalary,;
oTxtDAAmt,oTxtHRAAmt,;
oCboMonth ,oTxtSalaryAdvance,oTxtMobRecov,;
oTxtPFArrers,oTxtIncentives,oTxtNoOfLeaves ,;
oTxtMobBill, oTxtPayDate,oBtnsave;
oTxtName :=oDlg:aControls[23]
oTxtBranch:=oDlg:aControls[24]
oTxtDepartment:=oDlg:aControls[25]
oCboMonth:=oDlg:aControls[26]
oTxtPayDate:=oDlg:aControls[27]
oTxtBasicSalary:=oDlg:aControls[28]
oTxtTotalSalary:=oDlg:aControls[44]
oTxtPfAmt:=oDlg:aControls[29]
oTxtTaxAmt:=oDlg:aControls[30]
oTxtNoOfLeaves:=oDlg:aControls[31]
oTxtLOPAmt:=oDlg:aControls[32]
oTxtInsAmt:=oDlg:aControls[33]
oTxtOtherDeduction:=oDlg:aControls[38]
oTxtDAAmt:=oDlg:aControls[39]
oTxtHRAAmt:=oDlg:aControls[40]
oTxtTAAmt:=oDlg:aControls[41]
oTxtOtherAdditions:=oDlg:aControls[43]
oTxtSalaryAdvance:=oDlg:aControls[34]
oTxtMobRecov:=oDlg:aControls[37]
oTxtPFArrers:=oDlg:aControls[35]
oTxtIncentives:=oDlg:aControls[42]
oTxtMobBill :=oDlg:aControls[36]
oBtnsave:=oDlg:aControls[45]
oTxtName:Varput(padr("",40))
oTxtBranch:Varput(padr("",40))
oTxtDepartment:Varput(padr("",40))
oTxtBasicSalary:Varput(Int(0))
oTxtTotalSalary:Varput(Int(0))
oTxtPfAmt:Varput(Int(0))
oTxtTaxAmt:Varput(Int(0))
oTxtLOPAmt:Varput(Int(0))
oTxtInsAmt:Varput(Int(0))
oTxtSalaryAdvance:Varput(Int(0))
oTxtOtherDeduction:Varput(Int(0))
oTxtDAAmt:Varput(Int(0))
oTxtHRAAmt:Varput(Int(0))
oTxtTAAmt:Varput(Int(0))
oTxtOtherAdditions:Varput(Int(0))
oTxtTotalSalary:Varput(Int(0))
oTxtMobRecov:Varput(Int(0))
oTxtPFArrers:Varput(Int(0))
oTxtIncentives:Varput(Int(0))
oTxtNoOfLeaves:Varput(Int(0))
oTxtMobBill:Varput(Int(0))
oCboMonth:Varput(Str(0))
oTxtPayDate:Varput(CToD(""))
oBtnsave:SetFile( "Icons\Save.bmp",)
oDlg:update()
RETURN Nil
sajith
Re: Tab Order
Dear Sajith,
It all depends on the style of the coding which you adopt. Since you have hard coded the oDlg:aControls[nNo] it may be confusing to you to change the order. If I were to write the code, I would not have used that technique and would have opted some other way, so that editing of the TAB order does not cause too much of complications and does not force me to re-check/alter the whole code in my PRG.
While coding, I always keep in my mind that my client's requirements may change on a later date and I may have to alter the code, and a small change in a code should not create a havoc and should not invite unwanted problems into my app.
Regards
Anser
It all depends on the style of the coding which you adopt. Since you have hard coded the oDlg:aControls[nNo] it may be confusing to you to change the order. If I were to write the code, I would not have used that technique and would have opted some other way, so that editing of the TAB order does not cause too much of complications and does not force me to re-check/alter the whole code in my PRG.
While coding, I always keep in my mind that my client's requirements may change on a later date and I may have to alter the code, and a small change in a code should not create a havoc and should not invite unwanted problems into my app.
Regards
Anser
Re: Tab Order
Many Many thanks for ur Wise suggestion ,
Regards,
sajith
can u Pls help me to find a better way to extract the Specific controls(Object) from a Dialog so that it will be really help full for me .Since you have hard coded the oDlg:aControls[nNo] it may be confusing to you to change the order. If I were to write the code, I would not have used that technique and would have opted some other way.
Code: Select all
oTxtName :=oDlg:aControls[23]//My coding style
sajith
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: Tab Order
Dear Sajith,
I understand that you are passing the Dialog as parameter to the function and using aControls to extract the values from the controls. In your code you are using oDlg:aControls[] referenced by the array subscript no., the subscript no. of the controls changes when you change the order of the controls creation (ie when you wish to change the TAB order etc).
There are different ways to achieve this and one method is that you can use an array to hold the GET controls and then you could have passed the array as parameter to function. Here other well experienced gurus are available in this forum who may be able to give you much better ideas.
There are other user class named TPublic etc available which can be used instead of using array to hold the controls. If you use the TPublic class, you will be able to refer to the controls in a much meaningful way.
For. eg.
Hope you understand what I am trying to explain to you.
Regards
Anser
I understand that you are passing the Dialog as parameter to the function and using aControls to extract the values from the controls. In your code you are using oDlg:aControls[] referenced by the array subscript no., the subscript no. of the controls changes when you change the order of the controls creation (ie when you wish to change the TAB order etc).
There are different ways to achieve this and one method is that you can use an array to hold the GET controls and then you could have passed the array as parameter to function. Here other well experienced gurus are available in this forum who may be able to give you much better ideas.
Code: Select all
Local aMyControls:={nil,nil,nil,nil,nil,nil,nil}
...
...
@02.3,10 getaMyControls[1] VAR cVar1
@03.4,10 get aMyControls[2] VAR cVar2
@04.5,10 get aMyControls[3] VAR cVar3
@05.6,10 get aMyControls[4] VAR cVar4
@06.7,10 get aMyControls[5] VAR cVar5
@07.8,10 get aMyControls[6] VAR cVar6
@08.9,10 get aMyControls[7] VAR cVar7
DEFINE BUTTON aMyControl[9] .....
.....
ClearTextEmpPaySlipData(oDlg,aMyControl)
//------------------------------------------------------------------------------
FUNCTION ClearTextEmpPaySlipData(oDlg,aMyControl) //For Clearing All the Controls In the Dialog
//------------------------------------------------------------------------------
LOCAL oTxtTotalSalary,oTxtPfAmt,oTxtTaxAmt,oTxtLOPAmt,;
oTxtInsAmt,oTxtOtherDeduction, oTxtTAAmt,;
oTxtOtherAdditions,oTxtName ,oTxtBranch,;
oTxtDepartment,oTxtBasicSalary,;
oTxtDAAmt,oTxtHRAAmt,;
oCboMonth ,oTxtSalaryAdvance,oTxtMobRecov,;
oTxtPFArrers,oTxtIncentives,oTxtNoOfLeaves ,;
oTxtMobBill, oTxtPayDate,oBtnsave;
oTxtName :=aMyControl[1]
oTxtBranch:=aMyControl[2]
oTxtDepartment:=aMyControl[3]
oCboMonth:=aMyControl[4]
oTxtPayDate:=aMyControl[5]
oTxtBasicSalary:=aMyControl[6]
oTxtTotalSalary:=aMyControl[7]
...
....
oBtnsave:=aMyControl[8]
oTxtName:Varput(padr("",40))
oTxtBranch:Varput(padr("",40))
oTxtDepartment:Varput(padr("",40))
oTxtBasicSalary:Varput(Int(0))
oTxtTotalSalary:Varput(Int(0))
oTxtPfAmt:Varput(Int(0))
oTxtTaxAmt:Varput(Int(0))
oTxtLOPAmt:Varput(Int(0))
oTxtMobBill:Varput(Int(0))
oCboMonth:Varput(Str(0))
oTxtPayDate:Varput(CToD(""))
oBtnsave:SetFile( "Icons\Save.bmp",)
oDlg:update()
RETURN Nil
For. eg.
Code: Select all
oMyControl:=TPublic():New(.T.)
oMyControl:cUserName1:=Space(30) // Used to hold data while Adding New User
oMyControl:cPassword1:=Space(10) // Used to hold data while Adding New User
oMyControl:nStatus1 :=1 // Used to hold data while Adding New User
oMyControl:oUserName1:=NIL // Used to hold Objects while Adding New User
oMyControl:oPassword1:=NIL // Used to hold Objects while Adding New User
oMyControl:oStatus1 :=NIL // Used to hold Objects while Adding New User
@01.1,05 get oMyControl:oUserName1 VAR oMyControl:cUserName1 of ..
@02.3,05 get oMyControl:oPassword1 VAR oMyControl:cPassword1 of ...
@03.4,05 RADIO oMyControl:oStatus1 VAR oMyControl:nStatus1 of oFolder:aDialogs[1] ;
ITEMS "Enabled","Disabled" Update
.....
ClearTextEmpPaySlipData(oDlg,oMyControl)
Hope you understand what I am trying to explain to you.
Regards
Anser
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Tab Order
Sajith,
If you are using a DBF to store this data, then it is simple to use a database object. To clear all the fields you simply do:
oPaySlip:blank()
oDlg:refresh()
This is much simpler than your approach. All the data is held in an array and calling the blank() method refills the array with blank data.
You can read more about using database objects in some articles that I wrote which are available on my website at http://www.gointellitech.com.
Regards,
James
If you are using a DBF to store this data, then it is simple to use a database object. To clear all the fields you simply do:
oPaySlip:blank()
oDlg:refresh()
This is much simpler than your approach. All the data is held in an array and calling the blank() method refills the array with blank data.
You can read more about using database objects in some articles that I wrote which are available on my website at http://www.gointellitech.com.
Regards,
James
Re: Tab Order
Hi anserkk,
Where can I find the TPublic class?
Thanks
Code: Select all
oMyControl:=TPublic():New(.T.)
Thanks
Regards,
Hakan ONEMLI
Harbour & VS 2019 & FWH 20.12
Hakan ONEMLI
Harbour & VS 2019 & FWH 20.12
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Tab Order
I suggest rather than using TPublic either using a database class or creating your own class for the object. The database class will automatically create data for all the fieldnames.
James
James
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Tab Order
Sajith,
If you need to give the focus to a specific control then you can do it this way:
Please notice that .F. must be returned from the ON INIT clause to tell Windows that we are changing the focus sequence order using Method SetFocus()
If you need to give the focus to a specific control then you can do it this way:
Code: Select all
#include "FiveWin.ch"
function Main()
local oDlg, cFirst := Space( 20 ), cLast := Space( 20 )
DEFINE DIALOG oDlg TITLE "Test"
@ 1, 1 GET cFirst
@ 2, 1 GET cLast
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( oDlg:aControls[ 2 ]:SetFocus(), .F. )
return nil