Tutorials to .com

Tutorials to .com » Database » Foxpro » Grid control the use of VFP General entry interface design

Grid control the use of VFP General entry interface design

Print View , by: iSee ,Total views: 47 ,Word Count: 9806 ,Date: Sat, 18 Apr 2009 Time: 9:07 PM

Grid is a powerful vfp table (or grid) control, which provides much more powerful than the Browse window of the control. Grid is a container object that contains the object out, and out of the column header object contains objects and control objects shown are the property of their respective sets, so we can have full control of any one form element, the design of a universal input interface statements. Here we will discuss in detail how to use the Grid Control interface design generic entry, and a number of the design process to solve problems they encounter frequently.

First, the basic principles of thinking

Design flexibility, more versatile interface input approach is more appropriate: the use of data table (DBF file) to control the ranks of the Grid control to display information, display. Therefore, we will control the data source Grid Set RecordSource data table (DBF file), its data format, display, and the ranks of a message from the data tables were RowMsg.DBF (the control line forms that record information), ColMsg. DBF (Data Grid control format and control information out of) control. In addition, the general Grid Control designated the first column shows the message line, if a number of message field, can be connected to a handle.

Second, the preliminary preparatory work

1. To create table RowMsg.DBF, the table has two fields, Grid Control line used to display information:

Create Table RowMsg (Code c (5), Name C++ (33))

2. To create table ColMsg.DBF, the table has six fields for the control, showed that out of all forms of information:

Create Table ColMsg (Code C (5), Name C (20), NeedIn L (1), Field_Name C (10), Field_Type C (1), Field_Len N (3), Field_Dec N (3))

3. To create a form In_Grid, its attributes Name changed to "FrmGrid", Caption to "data entry / modification window"; in the form to place a Grid control, change its Name property "GridDat"; in the form Command placed the control of its attributes Name changed to "CmdExit", Caption to "close the exit."

Third, the preliminary design

1. First in the Init event of the form write the following code:

Set Talk Off
Set Safe Off
CLOSE ALL
With ThisForm
.AutoCenter=.T. &&
.ControlBox=.F. &&
.Width=_Screen.Width &&
EndWith
**/ColMsg.DBFDat.DBF **/
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru &&Dat.DBF
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code) &&RowMsg.DBFDat.DBF
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F. &&Grid,
.RecordMark=.F. &&Grid,
.ScrollBars=0 &&Grid,
.AllowHeaderSizing=.F.&&Grid
.AllowRowSizing=.F. &&Grid
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
**/,。/**
.Column1.ControlSource="Code+RowMsg.Name" &&2
.Column1.Enabled=.F. &&,
.Column1.Width=300
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=""
**/,。/**
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=90
EndWith
EndScan
**/,。/**
lnGridLen=.Column1.Width+Recc("ColMsg")*.Column2.Width+10
.Width=IIF(m.lnGridLen>ThisForm.Width*0.95,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2 &&
EndWith
Set Talk Off
Set Safe Off
CLOSE ALL
With ThisForm
.AutoCenter=.T. &&
.ControlBox=.F. &&
.Width=_Screen.Width &&
EndWith
**/ColMsg.DBFDat.DBF **/
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru &&Dat.DBF
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code) &&RowMsg.DBFDat.DBF
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F. &&Grid,
.RecordMark=.F. &&Grid,
.ScrollBars=0 &&Grid,
.AllowHeaderSizing=.F.&&Grid
.AllowRowSizing=.F. &&Grid
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
**/,。/**
.Column1.ControlSource="Code+RowMsg.Name" &&2
.Column1.Enabled=.F. &&,
.Column1.Width=300
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=""
**/,。/**
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=90
EndWith
EndScan
**/,。/**
lnGridLen=.Column1.Width+Recc("ColMsg")*.Column2.Width+10
.Width=IIF(m.lnGridLen>ThisForm.Width*0.95,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2 &&
EndWith
Set Talk Off
Set Safe Off
CLOSE ALL
With ThisForm
.AutoCenter=.T. &&
.ControlBox=.F. &&
.Width=_Screen.Width &&
EndWith
**/ColMsg.DBFDat.DBF **/
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru &&Dat.DBF
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code) &&RowMsg.DBFDat.DBF
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F. &&Grid,
.RecordMark=.F. &&Grid,
.ScrollBars=0 &&Grid,
.AllowHeaderSizing=.F.&&Grid
.AllowRowSizing=.F. &&Grid
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
**/,。/**
.Column1.ControlSource="Code+RowMsg.Name" &&2
.Column1.Enabled=.F. &&,
.Column1.Width=300
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=""
**/,。/**
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=90
EndWith
EndScan
**/,。/**
lnGridLen=.Column1.Width+Recc("ColMsg")*.Column2.Width+10
.Width=IIF(m.lnGridLen>ThisForm.Width*0.95,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2 &&
EndWith
Set Talk Off
Set Safe Off
CLOSE ALL
With ThisForm
.AutoCenter=.T. &&
.ControlBox=.F. &&
.Width=_Screen.Width &&
EndWith
**/ColMsg.DBFDat.DBF **/
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru &&Dat.DBF
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code) &&RowMsg.DBFDat.DBF
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F. &&Grid,
.RecordMark=.F. &&Grid,
.ScrollBars=0 &&Grid,
.AllowHeaderSizing=.F.&&Grid
.AllowRowSizing=.F. &&Grid
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
**/,。/**
.Column1.ControlSource="Code+RowMsg.Name" &&2
.Column1.Enabled=.F. &&,
.Column1.Width=300
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=""
**/,。/**
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=90
EndWith
EndScan
**/,。/**
lnGridLen=.Column1.Width+Recc("ColMsg")*.Column2.Width+10
.Width=IIF(m.lnGridLen>ThisForm.Width*0.95,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2 &&
EndWith
Set Talk Off
Set Safe Off
CLOSE ALL
With ThisForm
.AutoCenter=.T. &&
.ControlBox=.F. &&
.Width=_Screen.Width &&
EndWith
**/ColMsg.DBFDat.DBF **/
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru &&Dat.DBF
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code) &&RowMsg.DBFDat.DBF
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F. &&Grid,
.RecordMark=.F. &&Grid,
.ScrollBars=0 &&Grid,
.AllowHeaderSizing=.F.&&Grid
.AllowRowSizing=.F. &&Grid
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
**/,。/**
.Column1.ControlSource="Code+RowMsg.Name" &&2
.Column1.Enabled=.F. &&,
.Column1.Width=300
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=""
**/,。/**
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=90
EndWith
EndScan
**/,。/**
lnGridLen=.Column1.Width+Recc("ColMsg")*.Column2.Width+10
.Width=IIF(m.lnGridLen>ThisForm.Width*0.95,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2 &&
EndWith
Set Talk Off
Set Safe Off
CLOSE ALL
With ThisForm
.AutoCenter=.T. &&
.ControlBox=.F. &&
.Width=_Screen.Width &&
EndWith
**/ColMsg.DBFDat.DBF **/
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru &&Dat.DBF
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code) &&RowMsg.DBFDat.DBF
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F. &&Grid,
.RecordMark=.F. &&Grid,
.ScrollBars=0 &&Grid,
.AllowHeaderSizing=.F.&&Grid
.AllowRowSizing=.F. &&Grid
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
**/,。/**
.Column1.ControlSource="Code+RowMsg.Name" &&2
.Column1.Enabled=.F. &&,
.Column1.Width=300
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=""
**/,。/**
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=90
EndWith
EndScan
**/,。/**
lnGridLen=.Column1.Width+Recc("ColMsg")*.Column2.Width+10
.Width=IIF(m.lnGridLen>ThisForm.Width*0.95,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2 &&
EndWith
Set Talk Off
Set Safe Off
CLOSE ALL
With ThisForm
.AutoCenter=.T. &&
.ControlBox=.F. &&
.Width=_Screen.Width &&
EndWith
**/ColMsg.DBFDat.DBF **/
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru &&Dat.DBF
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code) &&RowMsg.DBFDat.DBF
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F. &&Grid,
.RecordMark=.F. &&Grid,
.ScrollBars=0 &&Grid,
.AllowHeaderSizing=.F.&&Grid
.AllowRowSizing=.F. &&Grid
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
**/,。/**
.Column1.ControlSource="Code+RowMsg.Name" &&2
.Column1.Enabled=.F. &&,
.Column1.Width=300
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=""
**/,。/**
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=90
EndWith
EndScan
**/,。/**
lnGridLen=.Column1.Width+Recc("ColMsg")*.Column2.Width+10
.Width=IIF(m.lnGridLen>ThisForm.Width*0.95,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2 &&
EndWith
Set Talk Off
Set Safe Off
CLOSE ALL
With ThisForm
.AutoCenter=.T. &&
.ControlBox=.F. &&
.Width=_Screen.Width &&
EndWith
**/ColMsg.DBFDat.DBF **/
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru &&Dat.DBF
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code) &&RowMsg.DBFDat.DBF
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F. &&Grid,
.RecordMark=.F. &&Grid,
.ScrollBars=0 &&Grid,
.AllowHeaderSizing=.F.&&Grid
.AllowRowSizing=.F. &&Grid
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
**/,。/**
.Column1.ControlSource="Code+RowMsg.Name" &&2
.Column1.Enabled=.F. &&,
.Column1.Width=300
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=""
**/,。/**
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=90
EndWith
EndScan
**/,。/**
lnGridLen=.Column1.Width+Recc("ColMsg")*.Column2.Width+10
.Width=IIF(m.lnGridLen>ThisForm.Width*0.95,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2 &&
EndWith
Set Talk Off
Set Safe Off
CLOSE ALL
With ThisForm
.AutoCenter=.T. &&
.ControlBox=.F. &&
.Width=_Screen.Width &&
EndWith
**/ColMsg.DBFDat.DBF **/
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru &&Dat.DBF
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code) &&RowMsg.DBFDat.DBF
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F. &&Grid,
.RecordMark=.F. &&Grid,
.ScrollBars=0 &&Grid,
.AllowHeaderSizing=.F.&&Grid
.AllowRowSizing=.F. &&Grid
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
**/,。/**
.Column1.ControlSource="Code+RowMsg.Name" &&2
.Column1.Enabled=.F. &&,
.Column1.Width=300
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=""
**/,。/**
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=90
EndWith
EndScan
**/,。/**
lnGridLen=.Column1.Width+Recc("ColMsg")*.Column2.Width+10
.Width=IIF(m.lnGridLen>ThisForm.Width*0.95,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2 &&
EndWith
Set Talk Off
Set Safe Off
CLOSE ALL
With ThisForm
.AutoCenter=.T. &&
.ControlBox=.F. &&
.Width=_Screen.Width &&
EndWith
**/ColMsg.DBFDat.DBF **/
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru &&Dat.DBF
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code) &&RowMsg.DBFDat.DBF
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F. &&Grid,
.RecordMark=.F. &&Grid,
.ScrollBars=0 &&Grid,
.AllowHeaderSizing=.F.&&Grid
.AllowRowSizing=.F. &&Grid
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
**/,。/**
.Column1.ControlSource="Code+RowMsg.Name" &&2
.Column1.Enabled=.F. &&,
.Column1.Width=300
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=""
**/,。/**
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=90
EndWith
EndScan
**/,。/**
lnGridLen=.Column1.Width+Recc("ColMsg")*.Column2.Width+10
.Width=IIF(m.lnGridLen>ThisForm.Width*0.95,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2 &&
EndWith
Set Talk Off
Set Safe Off
CLOSE ALL
With ThisForm
.AutoCenter=.T. &&
.ControlBox=.F. &&
.Width=_Screen.Width &&
EndWith
**/ColMsg.DBFDat.DBF **/
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru &&Dat.DBF
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code) &&RowMsg.DBFDat.DBF
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F. &&Grid,
.RecordMark=.F. &&Grid,
.ScrollBars=0 &&Grid,
.AllowHeaderSizing=.F.&&Grid
.AllowRowSizing=.F. &&Grid
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
**/,。/**
.Column1.ControlSource="Code+RowMsg.Name" &&2
.Column1.Enabled=.F. &&,
.Column1.Width=300
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=""
**/,。/**
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=90
EndWith
EndScan
**/,。/**
lnGridLen=.Column1.Width+Recc("ColMsg")*.Column2.Width+10
.Width=IIF(m.lnGridLen>ThisForm.Width*0.95,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2 &&
EndWith
Set Talk Off
Set Safe Off
CLOSE ALL
With ThisForm
.AutoCenter=.T. &&
.ControlBox=.F. &&
.Width=_Screen.Width &&
EndWith
**/ColMsg.DBFDat.DBF **/
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru &&Dat.DBF
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code) &&RowMsg.DBFDat.DBF
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F. &&Grid,
.RecordMark=.F. &&Grid,
.ScrollBars=0 &&Grid,
.AllowHeaderSizing=.F.&&Grid
.AllowRowSizing=.F. &&Grid
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
**/,。/**
.Column1.ControlSource="Code+RowMsg.Name" &&2
.Column1.Enabled=.F. &&,
.Column1.Width=300
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=""
**/,。/**
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=90
EndWith
EndScan
**/,。/**
lnGridLen=.Column1.Width+Recc("ColMsg")*.Column2.Width+10
.Width=IIF(m.lnGridLen>ThisForm.Width*0.95,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2 &&
EndWith
Set Talk Off
Set Safe Off
CLOSE ALL
With ThisForm
.AutoCenter=.T. &&
.ControlBox=.F. &&
.Width=_Screen.Width &&
EndWith
**/ColMsg.DBFDat.DBF **/
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru &&Dat.DBF
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code) &&RowMsg.DBFDat.DBF
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F. &&Grid,
.RecordMark=.F. &&Grid,
.ScrollBars=0 &&Grid,
.AllowHeaderSizing=.F.&&Grid
.AllowRowSizing=.F. &&Grid
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
**/,。/**
.Column1.ControlSource="Code+RowMsg.Name" &&2
.Column1.Enabled=.F. &&,
.Column1.Width=300
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=""
**/,。/**
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=90
EndWith
EndScan
**/,。/**
lnGridLen=.Column1.Width+Recc("ColMsg")*.Column2.Width+10
.Width=IIF(m.lnGridLen>ThisForm.Width*0.95,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2 &&
EndWith
Set Talk Off
Set Safe Off
CLOSE ALL
With ThisForm
.AutoCenter=.T. &&
.ControlBox=.F. &&
.Width=_Screen.Width &&
EndWith
**/ColMsg.DBFDat.DBF **/
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru &&Dat.DBF
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code) &&RowMsg.DBFDat.DBF
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F. &&Grid,
.RecordMark=.F. &&Grid,
.ScrollBars=0 &&Grid,
.AllowHeaderSizing=.F.&&Grid
.AllowRowSizing=.F. &&Grid
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
**/,。/**
.Column1.ControlSource="Code+RowMsg.Name" &&2
.Column1.Enabled=.F. &&,
.Column1.Width=300
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=""
**/,。/**
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=90
EndWith
EndScan
**/,。/**
lnGridLen=.Column1.Width+Recc("ColMsg")*.Column2.Width+10
.Width=IIF(m.lnGridLen>ThisForm.Width*0.95,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2 &&
EndWith
Set Talk Off
Set Safe Off
CLOSE ALL
With ThisForm
.AutoCenter=.T. &&
.ControlBox=.F. &&
.Width=_Screen.Width &&
EndWith
**/ColMsg.DBFDat.DBF **/
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru &&Dat.DBF
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code) &&RowMsg.DBFDat.DBF
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F. &&Grid,
.RecordMark=.F. &&Grid,
.ScrollBars=0 &&Grid,
.AllowHeaderSizing=.F.&&Grid
.AllowRowSizing=.F. &&Grid
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
**/,。/**
.Column1.ControlSource="Code+RowMsg.Name" &&2
.Column1.Enabled=.F. &&,
.Column1.Width=300
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=""
**/,。/**
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=90
EndWith
EndScan
**/,。/**
lnGridLen=.Column1.Width+Recc("ColMsg")*.Column2.Width+10
.Width=IIF(m.lnGridLen>ThisForm.Width*0.95,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2 &&
EndWith

2. CmdExit button in order to write the Click event code: ThisForm.Release

At this point, the form can be run smoothly.

Fourth, to further improve the

The form has a smooth run, but the existence of the following two major deficiencies:

1. Input focus does not automatically lower, that is, the first line in a field on the final play Enter key, the focus does not automatically go to the next line of the first field, but returned to the first line on the first field.

2. Message out (the most left one) can not be fixed, that is, the focus shifted to right with the input of information out of the screen will prompt out and no longer can be seen that the loss of the role of its message.

Now we come to discuss in detail and to address these two problems.

(A) the importation of auto-focus down

Resolve this problem the method can be used more. After the multi-comparison test, we believe that our form KeyPress event is more suitable to solve this problem (of course the use of Grid Control BeforeRowColChange events or incidents can be AfterRowColChange). KeyPress event in the user press and release a button when, by receiving the object of focus. Form available at the following two cases receive KeyPress event:

(1) does not contain any form of control or all controls are not visible or not activated. (2) form KeyPreview property is set to. T..

Obviously does not apply in this case (1) applies only to the situation (2). To this end, to be in the form of the Init event code to add the following code:

ThisForm.KeyPreview =. T.

And then in the form KeyPress event write the following code:

LPARAMETERS nKeyCode, nShiftAltCtrl &&,
**/GridTAB**/
With ThisForm.ActiveControl
IF Upper(.Name)='GRIDDAT' And (m.nKeyCode=13 OR m.nKeyCode=9)
if .ActiveColumn=Recc("ColMsg")+1 &&Grid
KeyBoard "{DnArrow}" Plain &&
Endif
ENDIF
EndWith
LPARAMETERS nKeyCode, nShiftAltCtrl &&,
**/GridTAB**/
With ThisForm.ActiveControl
IF Upper(.Name)='GRIDDAT' And (m.nKeyCode=13 OR m.nKeyCode=9)
if .ActiveColumn=Recc("ColMsg")+1 &&Grid
KeyBoard "{DnArrow}" Plain &&
Endif
ENDIF
EndWith
LPARAMETERS nKeyCode, nShiftAltCtrl &&,
**/GridTAB**/
With ThisForm.ActiveControl
IF Upper(.Name)='GRIDDAT' And (m.nKeyCode=13 OR m.nKeyCode=9)
if .ActiveColumn=Recc("ColMsg")+1 &&Grid
KeyBoard "{DnArrow}" Plain &&
Endif
ENDIF
EndWith
LPARAMETERS nKeyCode, nShiftAltCtrl &&,
**/GridTAB**/
With ThisForm.ActiveControl
IF Upper(.Name)='GRIDDAT' And (m.nKeyCode=13 OR m.nKeyCode=9)
if .ActiveColumn=Recc("ColMsg")+1 &&Grid
KeyBoard "{DnArrow}" Plain &&
Endif
ENDIF
EndWith
LPARAMETERS nKeyCode, nShiftAltCtrl &&,
**/GridTAB**/
With ThisForm.ActiveControl
IF Upper(.Name)='GRIDDAT' And (m.nKeyCode=13 OR m.nKeyCode=9)
if .ActiveColumn=Recc("ColMsg")+1 &&Grid
KeyBoard "{DnArrow}" Plain &&
Endif
ENDIF
EndWith

Thus, the input focus automatically down to basically solve the problem.

(B) fixed message out (the most left one)

Under normal circumstances, are often the first column records the entire message. foxpro have Lock the Browse command parameters can be specified in the browser window left field, we can see that the number of partitions, so that while browsing in the data, we can make sure the event of the level of rolling out a few of the most left when not visible, still left in the browser window Zoning out to see the contents of these. This field in the input data with more cases, very useful.

In the Grid Control can be by setting the Panel, Partition and PanelLink attribute to solve this problem. Here we have to solve some more difficult questions: When the Grid control panel the first column of the right can be seen, the disappearance of the first column of the left panel, because that's when the two do not need to show that the first column; Grid control when the right panel is not visible when the first column left panel shows the contents of the first column. Also fixed the so-called message out (the most left one).

Solutions to this problem are many, in order to simplify the programming, we are still using the form Init event and KeyPress events (of course, Grid Control can be BeforeRowColChange events or incidents AfterRowColChange).

In the form of the Init event code to add the following code:

ThisForm.GridDat.Panel=1 &&
ThisForm.GridDat.PanelLink=.T. &&
ThisForm.GridDat.Patition= ThisForm.GridDat.Column1.Width
**/:m.lnGridLenGrid**/
This.GridDat.Width=IIF(m.lnGridLen>This.Width*0.95,This.Width*0.95,m.lnGridLen)
This.GridDat.Left=(ThisForm.Width - This.GridDat.Width)/2 &&Grid
This.GridDat.Partition=IIF(m.lnGridLen>This.Width*0.95,This.GridDat.Column1.Width,0)

Note: Partition properties of whether to designate a form divided into two partitions, and specify the form in relation to the location of the left partition of the split. When the Partition is set to zero when the form did not split; that split location for non-zero value (actually the width of the left partition). Here, we determine what the width of the Grid control is more than the width of the form (actually a form width by 0.95 in order to have a certain gap around Grid to beautify the interface), the Partition is set to the width of message out to made to adapt to the previous message out of the fixed requirements; or Partition is set to zero (because no need for zoning at this time).

(C) Other details

After these series of improvements, the statements of generic entry interface has been basically achieved, but there are still a few details:

(1) initial access to the interface and recorded his party into the next when finished, prompt information will be repeated, such as Figure 1 that the solution: in the form of the Init event and KeyPress event code in the appropriate place to add the following code: KeyBoard "(TAB) (BACKTAB)" Plain

(2) We hope that in the last line of the final data in a carriage return after the fighting, the focus can be automatically moved to the command button so that we choose to carry out further work, such as "save from the". "Continue to entry". "To give up the closure of" and so on, the practice found in the KeyPress event code at appropriate locations to increase ThisForm.CmdExit.SetFocus () No, only with KeyBoard "(Ctrl + Tab)" Plain achieve.

(3) does not set the horizontal and vertical scroll bars are clear advantages, first, the interface simple and beautiful, such as Figure 2 show, with horizontal and vertical scroll bar appears to the input interface is not concise, some beating about the bush, and left the bottom of the right partition on the vertical scroll bar is the small black district signs, driving around it can re-partition, which has been designed to undermine entry interface; second, greatly simplifies programming, such as click the horizontal scroll bar district at about Resolution will have problems (of course, Grid Control can be programmed to solve the Scrolled event). However, it is undeniablealso brought about the inconvenience of the whole, the main inconvenience is the whole(about Scroll through the continuous press TAB key, Shift + TAB key combination to achieve). Up and down throughoriginal PgUp / PgDn key solution, but this time using the PgUp / PgDn message will be zoning out with right out of the data does not correspond to the situation, so we redefine the PgUp / PgDn keys, in the form of Init event code to add the following 2 lines of code:

ON KEY LABEL PgUp IIF(Bof("Dat"),Application.DoCmd("=MessAgeBox('!',;
'')"),Application.DoCmd("SKIP -12"))
ON KEY LABEL PgDn IIF(EoF("Dat"),Application.DoCmd("=MessAgeBox(‘!’,;
’’)"),Application.DoCmd("SKIP 12"))
ON KEY LABEL PgUp IIF(Bof("Dat"),Application.DoCmd("=MessAgeBox('!',;
'')"),Application.DoCmd("SKIP -12"))
ON KEY LABEL PgDn IIF(EoF("Dat"),Application.DoCmd("=MessAgeBox(‘!’,;
’’)"),Application.DoCmd("SKIP 12"))
ON KEY LABEL PgUp IIF(Bof("Dat"),Application.DoCmd("=MessAgeBox('!',;
'')"),Application.DoCmd("SKIP -12"))
ON KEY LABEL PgDn IIF(EoF("Dat"),Application.DoCmd("=MessAgeBox(‘!’,;
’’)"),Application.DoCmd("SKIP 12"))

Note: DoCmd function, MessageBox function to achieve the following functions:

PgUp Scroll up by 12 lines, if the first line to prompt "is the first record!"; PgDn Scroll down by 12 lines, if the last line will prompt "is the last record!."

V. Conclusion

At this point, we have achieved a more satisfactory use of general-purpose Grid control input interface design. It should be noted that further improvement is still a lot of:

1. Message out and set the width of data columns. ColMsg.DBF available RowMsg.DBF and the corresponding field length to be multiplied by a coefficient, is also available on the RowMsg.DBF and set the corresponding field ColMsg.DBF directly determine its width. We adopt the former method.

2. Horizontal and vertical scroll bar settings. When more than 30 columns of data, a horizontal scroll bar has become more convenient for them. Unfortunately, VFP itself did not provide a separate scroll bar control (of course lose some of the aesthetic interface simple, using the Grid's own scroll bar control can be achieved completely), so we can only use the OLE control, such as MicroSoft Forms 2.0 ScrollBar, and by setting the corresponding attributes and event programming, to solve this problem. Due to space limitations of this article is no longer discussed. In addition, do not use Grid control and direct the use to solve these problems have been a better third-party OLE controls, such as TrueDBGrid, FlexGrid, MicroSoft DataGrid Control, etc., is also a solution, but not the scope of this article is no longer discussed.

In this case Windows9x/WindowsXP, Visual FoxPro 5.0/6.0 adopted under the debugger. All events in this case a complete code of laws.

Form a complete code of the Init event is as follows:

Set Talk Off
Set Safe Off
CLOSE ALL
ON KEY LABEL PgUp IIF(Bof("Dat"),Application.DoCmd("=MessAgeBox('!','')"),Application.DoCmd("SKIP -12"))
ON KEY LABEL PgDn IIF(EoF("Dat"),Application.DoCmd("=MessAgeBox(‘!’,’’)"),Application.DoCmd("SKIP 12"))
With ThisForm
.KeyPreview=.T.
.AutoCenter=.T.
.ControlBox=.F.
.Width=_Screen.Width
EndWith
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code)
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F.
.ScrollBars=0
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
.Column1.ControlSource="Code+RowMsg.Name"
.Column1.Enabled=.F.
.Column1.Width=Len(Code+RowMsg.Name)*8
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=" "
.Panel=1
.PanelLink=.T.
lnGridLen=.Column1.Width+10
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=Len(.Header1.Caption)*7
lnGridLen=m.lnGridLen+.Width
EndWith
EndScan
.Width=IIF(m.lnGridLen>ThisForm.Width,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
.Partition=IIF(m.lnGridLen>ThisForm.Width*.95,.Column1.Width,0)
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2
EndWith
KeyBoard "{Tab}{BackTab}" Plain
KeyPress:
LPARAMETERS nKeyCode, nShiftAltCtrl
With ThisForm.ActiveControl
IF Upper(.Name)='GRIDDAT' And (m.nKeyCode=13 OR m.nKeyCode=9)
IF .ActiveColumn=Recc("ColMsg")+1
KeyBoard "{DnArrow}" Plain
KeyBoard "{Tab}{BackTab}" Plain
If .ActiveRow=Recc("RowMsg")
KeyBoard "{Ctrl+Tab}" Plain
Endif
ENDIF
ENDIF
EndWith
CmdExitClick:
ON KEY LABEL PgUp
ON KEY LABEL PgDn
Close All
Eras TmpColMsg.DBF
Eras TmpRowMsg.IDX
ThisForm.Release
Set Talk Off
Set Safe Off
CLOSE ALL
ON KEY LABEL PgUp IIF(Bof("Dat"),Application.DoCmd("=MessAgeBox('!','')"),Application.DoCmd("SKIP -12"))
ON KEY LABEL PgDn IIF(EoF("Dat"),Application.DoCmd("=MessAgeBox(‘!’,’’)"),Application.DoCmd("SKIP 12"))
With ThisForm
.KeyPreview=.T.
.AutoCenter=.T.
.ControlBox=.F.
.Width=_Screen.Width
EndWith
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code)
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F.
.ScrollBars=0
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
.Column1.ControlSource="Code+RowMsg.Name"
.Column1.Enabled=.F.
.Column1.Width=Len(Code+RowMsg.Name)*8
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=" "
.Panel=1
.PanelLink=.T.
lnGridLen=.Column1.Width+10
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=Len(.Header1.Caption)*7
lnGridLen=m.lnGridLen+.Width
EndWith
EndScan
.Width=IIF(m.lnGridLen>ThisForm.Width,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
.Partition=IIF(m.lnGridLen>ThisForm.Width*.95,.Column1.Width,0)
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2
EndWith
KeyBoard "{Tab}{BackTab}" Plain
KeyPress:
LPARAMETERS nKeyCode, nShiftAltCtrl
With ThisForm.ActiveControl
IF Upper(.Name)='GRIDDAT' And (m.nKeyCode=13 OR m.nKeyCode=9)
IF .ActiveColumn=Recc("ColMsg")+1
KeyBoard "{DnArrow}" Plain
KeyBoard "{Tab}{BackTab}" Plain
If .ActiveRow=Recc("RowMsg")
KeyBoard "{Ctrl+Tab}" Plain
Endif
ENDIF
ENDIF
EndWith
CmdExitClick:
ON KEY LABEL PgUp
ON KEY LABEL PgDn
Close All
Eras TmpColMsg.DBF
Eras TmpRowMsg.IDX
ThisForm.Release
Set Talk Off
Set Safe Off
CLOSE ALL
ON KEY LABEL PgUp IIF(Bof("Dat"),Application.DoCmd("=MessAgeBox('!','')"),Application.DoCmd("SKIP -12"))
ON KEY LABEL PgDn IIF(EoF("Dat"),Application.DoCmd("=MessAgeBox(‘!’,’’)"),Application.DoCmd("SKIP 12"))
With ThisForm
.KeyPreview=.T.
.AutoCenter=.T.
.ControlBox=.F.
.Width=_Screen.Width
EndWith
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code)
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F.
.ScrollBars=0
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
.Column1.ControlSource="Code+RowMsg.Name"
.Column1.Enabled=.F.
.Column1.Width=Len(Code+RowMsg.Name)*8
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=" "
.Panel=1
.PanelLink=.T.
lnGridLen=.Column1.Width+10
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=Len(.Header1.Caption)*7
lnGridLen=m.lnGridLen+.Width
EndWith
EndScan
.Width=IIF(m.lnGridLen>ThisForm.Width,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
.Partition=IIF(m.lnGridLen>ThisForm.Width*.95,.Column1.Width,0)
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2
EndWith
KeyBoard "{Tab}{BackTab}" Plain
KeyPress:
LPARAMETERS nKeyCode, nShiftAltCtrl
With ThisForm.ActiveControl
IF Upper(.Name)='GRIDDAT' And (m.nKeyCode=13 OR m.nKeyCode=9)
IF .ActiveColumn=Recc("ColMsg")+1
KeyBoard "{DnArrow}" Plain
KeyBoard "{Tab}{BackTab}" Plain
If .ActiveRow=Recc("RowMsg")
KeyBoard "{Ctrl+Tab}" Plain
Endif
ENDIF
ENDIF
EndWith
CmdExitClick:
ON KEY LABEL PgUp
ON KEY LABEL PgDn
Close All
Eras TmpColMsg.DBF
Eras TmpRowMsg.IDX
ThisForm.Release
Set Talk Off
Set Safe Off
CLOSE ALL
ON KEY LABEL PgUp IIF(Bof("Dat"),Application.DoCmd("=MessAgeBox('!','')"),Application.DoCmd("SKIP -12"))
ON KEY LABEL PgDn IIF(EoF("Dat"),Application.DoCmd("=MessAgeBox(‘!’,’’)"),Application.DoCmd("SKIP 12"))
With ThisForm
.KeyPreview=.T.
.AutoCenter=.T.
.ControlBox=.F.
.Width=_Screen.Width
EndWith
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code)
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F.
.ScrollBars=0
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
.Column1.ControlSource="Code+RowMsg.Name"
.Column1.Enabled=.F.
.Column1.Width=Len(Code+RowMsg.Name)*8
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=" "
.Panel=1
.PanelLink=.T.
lnGridLen=.Column1.Width+10
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=Len(.Header1.Caption)*7
lnGridLen=m.lnGridLen+.Width
EndWith
EndScan
.Width=IIF(m.lnGridLen>ThisForm.Width,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
.Partition=IIF(m.lnGridLen>ThisForm.Width*.95,.Column1.Width,0)
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2
EndWith
KeyBoard "{Tab}{BackTab}" Plain
KeyPress:
LPARAMETERS nKeyCode, nShiftAltCtrl
With ThisForm.ActiveControl
IF Upper(.Name)='GRIDDAT' And (m.nKeyCode=13 OR m.nKeyCode=9)
IF .ActiveColumn=Recc("ColMsg")+1
KeyBoard "{DnArrow}" Plain
KeyBoard "{Tab}{BackTab}" Plain
If .ActiveRow=Recc("RowMsg")
KeyBoard "{Ctrl+Tab}" Plain
Endif
ENDIF
ENDIF
EndWith
CmdExitClick:
ON KEY LABEL PgUp
ON KEY LABEL PgDn
Close All
Eras TmpColMsg.DBF
Eras TmpRowMsg.IDX
ThisForm.Release
Set Talk Off
Set Safe Off
CLOSE ALL
ON KEY LABEL PgUp IIF(Bof("Dat"),Application.DoCmd("=MessAgeBox('!','')"),Application.DoCmd("SKIP -12"))
ON KEY LABEL PgDn IIF(EoF("Dat"),Application.DoCmd("=MessAgeBox(‘!’,’’)"),Application.DoCmd("SKIP 12"))
With ThisForm
.KeyPreview=.T.
.AutoCenter=.T.
.ControlBox=.F.
.Width=_Screen.Width
EndWith
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code)
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F.
.ScrollBars=0
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
.Column1.ControlSource="Code+RowMsg.Name"
.Column1.Enabled=.F.
.Column1.Width=Len(Code+RowMsg.Name)*8
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=" "
.Panel=1
.PanelLink=.T.
lnGridLen=.Column1.Width+10
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=Len(.Header1.Caption)*7
lnGridLen=m.lnGridLen+.Width
EndWith
EndScan
.Width=IIF(m.lnGridLen>ThisForm.Width,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
.Partition=IIF(m.lnGridLen>ThisForm.Width*.95,.Column1.Width,0)
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2
EndWith
KeyBoard "{Tab}{BackTab}" Plain
KeyPress:
LPARAMETERS nKeyCode, nShiftAltCtrl
With ThisForm.ActiveControl
IF Upper(.Name)='GRIDDAT' And (m.nKeyCode=13 OR m.nKeyCode=9)
IF .ActiveColumn=Recc("ColMsg")+1
KeyBoard "{DnArrow}" Plain
KeyBoard "{Tab}{BackTab}" Plain
If .ActiveRow=Recc("RowMsg")
KeyBoard "{Ctrl+Tab}" Plain
Endif
ENDIF
ENDIF
EndWith
CmdExitClick:
ON KEY LABEL PgUp
ON KEY LABEL PgDn
Close All
Eras TmpColMsg.DBF
Eras TmpRowMsg.IDX
ThisForm.Release
Set Talk Off
Set Safe Off
CLOSE ALL
ON KEY LABEL PgUp IIF(Bof("Dat"),Application.DoCmd("=MessAgeBox('!','')"),Application.DoCmd("SKIP -12"))
ON KEY LABEL PgDn IIF(EoF("Dat"),Application.DoCmd("=MessAgeBox(‘!’,’’)"),Application.DoCmd("SKIP 12"))
With ThisForm
.KeyPreview=.T.
.AutoCenter=.T.
.ControlBox=.F.
.Width=_Screen.Width
EndWith
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code)
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F.
.ScrollBars=0
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
.Column1.ControlSource="Code+RowMsg.Name"
.Column1.Enabled=.F.
.Column1.Width=Len(Code+RowMsg.Name)*8
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=" "
.Panel=1
.PanelLink=.T.
lnGridLen=.Column1.Width+10
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=Len(.Header1.Caption)*7
lnGridLen=m.lnGridLen+.Width
EndWith
EndScan
.Width=IIF(m.lnGridLen>ThisForm.Width,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
.Partition=IIF(m.lnGridLen>ThisForm.Width*.95,.Column1.Width,0)
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2
EndWith
KeyBoard "{Tab}{BackTab}" Plain
KeyPress:
LPARAMETERS nKeyCode, nShiftAltCtrl
With ThisForm.ActiveControl
IF Upper(.Name)='GRIDDAT' And (m.nKeyCode=13 OR m.nKeyCode=9)
IF .ActiveColumn=Recc("ColMsg")+1
KeyBoard "{DnArrow}" Plain
KeyBoard "{Tab}{BackTab}" Plain
If .ActiveRow=Recc("RowMsg")
KeyBoard "{Ctrl+Tab}" Plain
Endif
ENDIF
ENDIF
EndWith
CmdExitClick:
ON KEY LABEL PgUp
ON KEY LABEL PgDn
Close All
Eras TmpColMsg.DBF
Eras TmpRowMsg.IDX
ThisForm.Release
Set Talk Off
Set Safe Off
CLOSE ALL
ON KEY LABEL PgUp IIF(Bof("Dat"),Application.DoCmd("=MessAgeBox('!','')"),Application.DoCmd("SKIP -12"))
ON KEY LABEL PgDn IIF(EoF("Dat"),Application.DoCmd("=MessAgeBox(‘!’,’’)"),Application.DoCmd("SKIP 12"))
With ThisForm
.KeyPreview=.T.
.AutoCenter=.T.
.ControlBox=.F.
.Width=_Screen.Width
EndWith
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code)
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F.
.ScrollBars=0
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
.Column1.ControlSource="Code+RowMsg.Name"
.Column1.Enabled=.F.
.Column1.Width=Len(Code+RowMsg.Name)*8
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=" "
.Panel=1
.PanelLink=.T.
lnGridLen=.Column1.Width+10
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=Len(.Header1.Caption)*7
lnGridLen=m.lnGridLen+.Width
EndWith
EndScan
.Width=IIF(m.lnGridLen>ThisForm.Width,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
.Partition=IIF(m.lnGridLen>ThisForm.Width*.95,.Column1.Width,0)
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2
EndWith
KeyBoard "{Tab}{BackTab}" Plain
KeyPress:
LPARAMETERS nKeyCode, nShiftAltCtrl
With ThisForm.ActiveControl
IF Upper(.Name)='GRIDDAT' And (m.nKeyCode=13 OR m.nKeyCode=9)
IF .ActiveColumn=Recc("ColMsg")+1
KeyBoard "{DnArrow}" Plain
KeyBoard "{Tab}{BackTab}" Plain
If .ActiveRow=Recc("RowMsg")
KeyBoard "{Ctrl+Tab}" Plain
Endif
ENDIF
ENDIF
EndWith
CmdExitClick:
ON KEY LABEL PgUp
ON KEY LABEL PgDn
Close All
Eras TmpColMsg.DBF
Eras TmpRowMsg.IDX
ThisForm.Release
Set Talk Off
Set Safe Off
CLOSE ALL
ON KEY LABEL PgUp IIF(Bof("Dat"),Application.DoCmd("=MessAgeBox('!','')"),Application.DoCmd("SKIP -12"))
ON KEY LABEL PgDn IIF(EoF("Dat"),Application.DoCmd("=MessAgeBox(‘!’,’’)"),Application.DoCmd("SKIP 12"))
With ThisForm
.KeyPreview=.T.
.AutoCenter=.T.
.ControlBox=.F.
.Width=_Screen.Width
EndWith
Sele 0
Use ColMsg
Copy To TmpStru Field Field_Name,Field_Type,Field_Len,Field_Dec
Copy To TmpColMsg For NeedIn
Create Dat From TmpStru
Eras TmpStru.DBF
Sele 0
Use TmpColMsg Alias ColMsg
Sele 0
Use RowMsg
Index On AllTrim(Code) To TmpRowMsg
Scan
Insert Into Dat(Code) Values (RowMsg.Code)
EndScan
Sele Dat
Go Top
Set Rela To AllTrim(Code) Into RowMsg
With ThisForm.GridDat
.FontName=""
.FontSize=10
.DeleteMark=.F.
.ScrollBars=0
.ColumnCount=Recc("ColMsg")+1
.RecordSourceType=2
.RecordSource="Dat"
.Column1.ControlSource="Code+RowMsg.Name"
.Column1.Enabled=.F.
.Column1.Width=Len(Code+RowMsg.Name)*8
.Column1.BackColor=RGB(192,192,192)
.Column1.Header1.Caption=" "
.Panel=1
.PanelLink=.T.
lnGridLen=.Column1.Width+10
Sele ColMsg
Scan
lcCol=AllTrim(Str(Recn()+1,5))
With .Column&lcCol.
.ControlSource="Dat."+Alltrim(Field_Name)
.Header1.Caption=AllTrim(Name)
.Width=Len(.Header1.Caption)*7
lnGridLen=m.lnGridLen+.Width
EndWith
EndScan
.Width=IIF(m.lnGridLen>ThisForm.Width,ThisForm.Width*0.95,m.lnGridLen)
.Left=(ThisForm.Width - .Width)/2
.Partition=IIF(m.lnGridLen>ThisForm.Width*.95,.Column1.Width,0)
ThisForm.CmdExit.Left= (ThisForm.Width - ThisForm.CmdExit.Width)/2
EndWith
KeyBoard "{Tab}{BackTab}" Plain
KeyPress:
LPARAMETERS nKeyCode, nShiftAltCtrl
With ThisForm.ActiveControl
IF Upper(.Name)='GRIDDAT' And (m.nKeyCode=13 OR m.nKeyCode=9)
IF .ActiveColumn=Recc("ColMsg")+1
KeyBoard "{DnArrow}" Plain
KeyBoard "{Tab}{BackTab}" Plain
If .ActiveRow=Recc("RowMsg")
KeyBoard "{Ctrl+Tab}" Plain
Endif
ENDIF
ENDIF
EndWith
CmdExitClick:
ON KEY LABEL PgUp
ON KEY LABEL PgDn
Close All
Eras TmpColMsg.DBF
Eras TmpRowMsg.IDX
ThisForm.Release
Set Talk Off
Set Safe Off
CLOSE ALL
ON KEY LABEL PgUp IIF(Bof("Dat"),Application.DoCmd("=MessAgeBox('!','')"),Application.DoCmd("SKIP -12"))
ON KEY LABEL PgDn IIF(EoF("Dat"),Application.DoCmd("=MessAgeBox(‘!’,’’)"),Application.DoCmd("SKIP 12"))
With ThisForm
.KeyPreview=.T.
.AutoCenter=.T.
.ControlBox=.F.
.Width=_Screen.Width
EndWith
Sele 0
Use ColMsg
Copy To TmpSt


FoxPro Tutorial Articles


Can't Find What You're Looking For?


Rating: 0.0

Comments

No comments posted.