TheLazyPig
Programmer
Hi again I have a Clear button that when I click it should remove the data from my grid without actually deleting it. I can only clear textbox but grid stays the same. Thank you
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
PUBLIC go_Form
go_Form = CREATEOBJECT("frmForm")
go_Form.Show
READ Events
CLEAR ALL
DEFINE CLASS frmForm As Form
Width = 420
Height = 360
MinWidth = 420
MinHeight = 360
MaxWidth = 420
MaxHeight = 360
AutoCenter = .T.
*!* Add a grid to the form
Add Object grdNames as Grid with;
Visible = .F., ;
Top = 48, Left = 18, Width = 390, Height = 264, DeleteMark = .F.
*!* Add object Labels
ADD OBJECT lblInfo as Label WITH ;
Top = 12, Left = 280, Autosize = .T., FontSize = 8, FontItalic = .T., ;
Caption = "Number of Records: "
ADD OBJECT lblSearch as Label WITH ;
Top = 12, Left = 12, Autosize = .T., FontSize = 8, FontItalic = .T., ;
Caption = "Enter string to search for in Name"
*!* Add object Textbox
ADD OBJECT txtSearch as Textbox WITH ;
Top = 12, Left = 192, Width = 60, Height = 24
*!* ADD a Browse button - allows you to filter the underlying table(s)
ADD OBJECT cmdBrowse As CommandButton WITH ;
Width=60, Height=30, Left=84, Top=318, Caption="Browse"
PROCEDURE cmdBrowse.Click()
LOCAL lcAlias
lcAlias = ALIAS()
SELECT cName, nMeters, nSquare, nVolume ;
FROM tblNames ;
WHERE IIF(EMPTY(ALLTRIM(ThisForm.txtSearch.Value)), .T., AT(ALLTRIM(ThisForm.txtSearch.Value), cName) != 0) ;
INTO CURSOR csrResults
Thisform.lblInfo.Caption = "Number of Records: " + TRANSFORM(_Tally, "999,999")
WITH ThisForm.grdNames
.ColumnCount = -1
.RecordSource = "csrResults"
.Visible = .T.
.ReadOnly = .T.
.SetAll("Sparse", .F., "Column")
.Column1.Width = 72
.Column1.Header1.Caption = "Name"
.Column1.Text1.FontBold = .T.
.Column1.Text1.FontItalic = .T.
.Column2.Width = 72
.Column2.Header1.Caption = "Me"
.Column2.Text1.InputMask = "9,999.99"
.Column3.Width = 90
.Column3.Header1.Caption = "Sq"
.Column3.Text1.InputMask = "999,999.99"
.Column4.Width = 90
.Column4.Header1.Caption = "Vo"
.Column4.Text1.InputMask = "999,999,999.99"
ENDWITH
SELECT (lcAlias)
ENDPROC
[highlight #FCE94F]*!* Add clearbutton to the form
ADD OBJECT cmdClear As CommandButton WITH ;
Width=60, Height=30, Left=150, Top=318, Caption="Clear"
PROCEDURE cmdClear.Click()
ThisForm.grdNames.Visible = !(ThisForm.grdNames.Visible)
ThisForm.cmdBrowse.Enabled = IIF(ThisForm.grdNames.Visible, .T., .F.)
This.Caption = IIF(ThisForm.grdNames.Visible, "Clear", "Restore")
ENDPROC[/highlight]
*!* Add exitbutton to the form
ADD OBJECT cmdExit As CommandButton WITH ;
Width=60, Height=30, Left=18, Top=318, Caption="Exit"
PROCEDURE cmdExit.Click()
CLOSE ALL
CLEAR Events
ThisForm.Release
ENDPROC
*!* ADD code to form's events
PROCEDURE Destroy()
ThisForm.cmdExit.Click()
ENDPROC
PROCEDURE Load()
IF !FILE("tblNames.dbf")
Create Table tblNames (cName C(10), nMeters I, nSquare I, nVolume I )
For li_I = 1 to 500
INSERT INTO tblNames (cName, nMeters, nSquare, nVolume) ;
VALUES ("Name" + PADL(li_I,3,"0"), li_I, li_I ^ 2, li_I ^ 3)
Next li_I
ELSE
USE tblNames
ENDIF
ENDPROC
ENDDEFINE
USE ?
BROWSE NAME oBrowse NOWAIT
? oBrowse.baseclass
select * from myOrigCrs where 1 != 1 into cursor myOrigCrs_temp
Thisform.myGrid.Recordsorce = [myOrigCrs_Temp]
use in select( [myOrigCrs] )
select * from myOrigCrs_Temp into myOrigCrs readwrite
Thisform.myGrid.Recordsorce = [myOrigCrs]
use in select( [myOrigCrs_Temp] )
Thisform.Refresh