Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > Add controls to another form

Forum

Search UsersRules
Add controls to another form
#1
Interested
Points:: 15
Joined:: Oct 27, 2011

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

Profile
#2
Just came
Points:: 0
Joined:: Jan 30, 2012

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

Profile
#3
Interested
Points:: 15
Joined:: Oct 27, 2011

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.

Profile
#4
Active user
Points:: 32
Joined:: Sep 16, 2011

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.

Profile
#5
Active user
Points:: 32
Joined:: Sep 16, 2011

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

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.