Add controls to another form

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

I'm trying to write a code witch will open any form (for example, any report form) and add some controls to the end off the form with will serve for the common logic of these forms. So I tried to add them with the following code:

Code
   BottomGroup = Items.Add ("BottomPanel", Type("FormGroup"));
   BottomGroup.Type = FormGroupType.ButtonGroup;
   Button = Items.Add("OKButton", Type("FormButton"), BottomGroup);
   Button.Type = FormButtonType.UsualButton;
   Button.CommandName = "CommonCommand.SaveReport";

The problem is that "CommonCommand.SaveReport" is unrecognized by the system no matter that the handler exist. Also these controls does not appear in the form. Do I need to do some more actions to display them?
The code is executed in the OnCreateAtServer event

 
#2
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Jan 30, 2012
Company:

I think the better way is put this controls to form in design mode, and manage controls visibility from program code.

 
#3
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

This is not the case for me. The reason I'm trying to do it via code is that I have to add these controls to every form of one kind. So it is a waste of time and future problems if I'll try to ad them in designer.
Please help me with the solution.

 
#4
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Sep 16, 2011
Company: individual

The Syntax Assistant says that the CommandName keeps the name of the form command, in other cases (the common command for example) it is blank. So you can set the form's command there and call the common command inside of it.

 
#5
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Sep 16, 2011
Company: individual

Maybe this will be helpful also: form items have SetAction method.

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.