This is a migrated thread and some comments may be shown as answers.

How to dynamically add controls to a window

1 Answer 275 Views
Window
This is a migrated thread and some comments may be shown as answers.
Simon Allport
Top achievements
Rank 2
Simon Allport asked on 10 Jan 2011, 10:46 AM
I want to be to be able to add textbox to the a rad window that is generated dynamically, but i can't see anything that will allow me to do this.
I was expecting to see some thing like ' Window.Child.Add();'

Can anyone help please?

RadWindow[] window = new RadWindow[5];
               for (int i = 0; i < 5; i++)
               {
                   window[i] = new RadWindow();
                      
                   window[i].Width = 250;
                   window[i].Height = 250;
                   window[i].Name = "Apples" + i;
                   window[i].Show();
               }

1 Answer, 1 is accepted

Sort by
0
Simon Allport
Top achievements
Rank 2
answered on 10 Jan 2011, 11:26 AM

Hi,
I found out how to do it. Using the 'Content' property.

Canvas canvas = new Canvas();
                   canvas.Width = 250;
                   canvas.Height = 250;
                   canvas.Name = "NoteCanvas";
                   Grid notegrid = new Grid();
                   TextBox txtbxNotes = new TextBox();
                   txtbxNotes.Text = "test" + i;
                   notegrid.Children.Add(txtbxNotes);
                   canvas.Children.Add(notegrid);
                   
               
                   window[i] = new RadWindow();
                   window[i].Width = 250;
                   window[i].Height = 250;
                   window[i].Name = "Apples" + i;
                   window[i].Content = canvas;
                   window[i].Show();

Thanks

Simon
Tags
Window
Asked by
Simon Allport
Top achievements
Rank 2
Answers by
Simon Allport
Top achievements
Rank 2
Share this question
or