Search This Blog

Showing posts with label if else. Show all posts
Showing posts with label if else. Show all posts

Changing Image or Picture of a Button

You can definitely change the picture of your bitton upon clicking, try these codes and play with the images. But first you have to prepare the image in JPEG.

IF THIS.Picture = "c:\images\edit.jpg"
THIS.Picture = "c:\images\save.jpg"
THISFORM.cmdClose.Picture = "c:\images\cancel.jpg"
ELSE
IF THISFORM.Combo1.Value = 'PESO'
lAnswer = MESSAGEBOX("Save changes?", 4, "Confirmation")
IF lAnswer = 6
THISFORM.cmdClose.Picture = "c:\images\close.jpg"
THISFORM.cmdEdit.Picture = "c:\images\edit.jpg"
ENDIF
ELSE THISFORM.COMBO1.Value = 'DOLLAR'
lAnswer = MESSAGEBOX("Save changes?", 4, "Confirmation")
IF lAnswer = 6
THISFORM.cmdClose.Picture = "c:\images\close.jpg"
THISFORM.cmdEdit.Picture = "c:\images\edit.jpg"
ENDIF
ENDIF
ENDIF

Cancel Close Code



If you want your button's picture to change when your Close/Cancel button also changed.

IF THIS.Picture = "c:\SalesMarket\Images\close.jpg"
THISFORM.Release()
ELSE
THIS.Picture = "c:\SalesMarket\Images\close.jpg"
THISFORM.ReadOnlyTrue()
THISFORM.Combo1.Enabled = .F.
THISFORM.cmdPrint.Enabled = .T.
THISFORM.cmdEdit.Enabled = .T.
THISFORM.cmdEdit.Picture = "c:\SalesMarket\Images\edit.jpg"
ENDIF

Empty Box

This code lets you use an Edit Box and will saved "Y" if the edit box is not empty otherwise save "N" if the edit box is blank. This is useful if you need to show in a View what Edit Box has an input and will not include blank.

SELECT QuestionTable
REPLACE q1comment WITH THISFORM.EDIT1.Value
IF EMPTY(THISFORM.EDIT1.Value)
REPLACE Q1Indicator WITH "N"
ELSE
REPLACE Q1Indicator WITH "Y"
ENDIF

If Else EndIf Code

You can utilize this code if you want your Command box caption to be change.

IF This.Caption = "Edit"
This.Caption = "Save"
Thisform.cmdClose.Caption= "Cancel"
ELSE
This.Caption = "Edit"
Thisform.cmdClose.Caption = "Close"
ENDIF