Vatsal
Vatsal

Reputation: 33

How to dynamically create layout for s:group in flex

I have a form inside which I have a button Onclick of which I am dynamically adding components to the form. I have successfully added components to the form. I have added a group to club them and give alignment. How can I add horizontal layout to the s:Group.

protected function ADD_CVE_ID_clickHandler(event:MouseEvent):void
            {
var textinput:TextInput = new TextInput;  
var dropdown:DropDownList = new DropDownList;
var textArea:TextArea = new TextArea;
var Grouptest:Group = new Group;
Grouptest.addElement(textinput);
Grouptest.addElement(dropdown);
Grouptest.addElement(textArea);
AddHere.addElement(Grouptest);
}

Upvotes: 0

Views: 693

Answers (1)

Sumit
Sumit

Reputation: 729

Use the following code for your requirement:-

        protected function ADD_CVE_ID_clickHandler(event:MouseEvent):void
        {
            var textinput:TextInput = new TextInput();  
            var dropdown:DropDownList = new DropDownList();
            var textArea:TextArea = new TextArea();
            var Grouptest:Group = new Group();
            var horizontalLayout:HorizontalLayout = new HorizontalLayout();
            Grouptest.layout = horizontalLayout;
            Grouptest.addElement(textinput);
            Grouptest.addElement(dropdown);
            Grouptest.addElement(textArea);
            AddHere.addElement(Grouptest);
        }

Upvotes: 1

Related Questions