INFO: SetAll('Value') Works for Text Boxes in Grids in VFP
ID: Q156580
|
The information in this article applies to:
-
Microsoft Visual FoxPro for Windows, versions 5.0, 6.0
SUMMARY
In Visual FoxPro 3.0 or 3.0b, issuing the following sets the value for any
text box on a form, but not text boxes contained in grids on that form:
<form>.Setall('value', '', 'textbox')
However, issuing the following sets properties for all text boxes, even
those contained in grids:
<form>.Setall(<other property besides value>, ;
<property value>, 'textbox')
In Visual FoxPro 5.0 and 6.0, the following works for all text boxes, even
those contained in grids within <form>:
<form>.Setall('value', '', 'textbox')
MORE INFORMATION
This change was made because the behavior of SetAll() is not consistent
across all properties in Visual FoxPro 3.0.
Use the following steps to reproduce this behavior.
- Run the following code from a program (.prg) file:
* Start of code example
*
PUBLIC oform
LOCAL lnI
CREATE TABLE table_1 (field1 C(10), field2 C(10))
FOR lnI=1 TO 3
INSERT INTO table_1 VALUES ('xx','yy')
ENDFOR
GO TOP
oform=CREATEOBJECT("grid_form")
oform.SHOW()
DEFINE CLASS grid_form AS FORM
AUTOCENTER = .T.
ADD OBJECT grid1 AS GRID WITH ;
Top = 10, ;
Left = 30, ;
RecordSource = 'Table_1', ;
ColumnCount = 2, ;
Name = "Grid1", ;
Column1.Sparse=.F., ;
Column2.Sparse=.F.
ADD OBJECT Text1 AS TEXTBOX WITH ;
Top = 220, ;
Left = 45, ;
Height = 23, ;
Width = 95, ;
Value = "zz", ;
Name = "Text1"
ADD OBJECT command1 AS COMMANDBUTTON WITH ;
Top = 218, ;
Left = 145, ;
Height = 27, ;
Width = 95, ;
Caption = "Set Values", ;
Name = "Command1"
ADD OBJECT command2 AS COMMANDBUTTON WITH ;
Top = 218, ;
Left = 245, ;
Height = 27, ;
Width = 95, ;
Caption = "Set FontSize", ;
Name = "Command2"
PROCEDURE DESTROY
USE
ENDPROC
PROCEDURE Command1.Click
THISFORM.SetAll('Value', '', 'TextBox')
* The above works for text boxes in grid columns
* under Visual FoxPro 5.0 only
THISFORM.Grid1.SetFocus()
ENDPROC
PROCEDURE Command2.Click
THISFORM.SetAll('FontSize', 12, 'textbox')
* The above works for text boxes in grid columns
* under Visual FoxPro 3.x and 5.0.
THISFORM.Grid1.SetFocus()
ENDPROC
ENDDEFINE
*
* End of code example
- Click on the Set FontSize command button. In both Visual FoxPro 3.0 and
5.0, the FontSize changes for all text boxes, even those within the
grid. Because the Sparse property is set to .F., the FontSize appears
for all cells within the grid, rather than the selected cell.
- Click on the Set Value command button. In both Visual FoxPro 3.0 and
5.0, the Value changes for the text box on the form. In Visual FoxPro
5.0 and 6.0, the values also changes for all text boxes within the
current record in the grid.
REFERENCES
Visual FoxPro 5.0 Help
Additional query words:
Keywords : kbsetup kbnokeyword kbVFp500 kbVFp600
Version : WINDOWS:5.0,6.0
Platform : WINDOWS
Issue type : kbinfo
|