Hello, Constantinos Anastasiou!
Depending on your task it might be better to change visibility of two commands, one of them will perform one action and hide itself then show another, which will perform another action.
The other way is to change the picture index, having a picture library with several states of your button attached as a picture.
If you want to display a picture on a form, for example if you edit a picture or perform some actions on it, you need to put it to the temp storage, get its address and attach as a picture after that to the string attribute, displayed as a picture.
For form buttons the Picture value can be either Empty or from the picture library of your application.
Here is a code sample for you, the configuration dump is attached to this message as well.
Code |
---|
&AtClient
Procedure ShowPicture(Command)
FileDialog = New FileDialog(FileDialogMode.Open);
FileDialog.Filter = NStr("en = 'All pictures (*.bmp;*.dib;*.rle;*.jpg;*.jpeg;*.tif;*.gif;*.png;*.ico;*.wmf;*.emf)|*.bmp;*.dib;*.rle;*.jpg;*.jpeg;*.tif;*.gif;*.png;*.ico;*.wmf;*.emf|'");
FileDialog.Show(New NotifyDescription("AfterChooseFile", ThisForm));
EndProcedure
&AtClient
Procedure AfterChooseFile(SelectedFiles, AdditionalParameters) Export
If ValueIsFilled(SelectedFiles) And SelectedFiles.Count() > 0 Then
PictureBinaryData = New BinaryData(SelectedFiles[0]);
PictureAddress = PutToTempStorage(PictureBinaryData);
Items.FormShowPicture.Picture = PictureLib.Back;
EndIf;
EndProcedure |