CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2007
    Posts
    116

    Lightbulb Create Buttons and Forms at runtime!

    I have to create buttons,forms at runtime after reading XML file.
    XML file will contain numbers of buttons and froms which i have to create run time.
    Please let me know right way.

  2. #2
    Join Date
    Apr 2007
    Location
    Florida
    Posts
    403

    Re: Create Buttons and Forms at runtime!

    Why don't ya try and attempt it first.

    Create a program to read an xml file and retrieve the number of buttons you want to create.

    At runtime, create a new System.Windows.Form. Add a button to the Form, and Show() the Form.

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Create Buttons and Forms at runtime!

    Check out xaml - it's what it does.

  4. #4
    Join Date
    Dec 2009
    Location
    Malta (GMT +1)
    Posts
    21

    Re: Create Buttons and Forms at runtime!

    well just to give this dude some stuff he wants,

    Declare a button, label, textbox w/e, set it's properties and then add to the form.

    so here is a button example

    Button myButton = new Button();
    myButton.Name = "btnMyButton";
    myButton.Text = "My Button";
    myButton.Size = new System.Drawing.Size(100, 20);
    myButton.Location = new System.Drawing.Point(this.Width - 150, this.Height - 125);
    this.Controls.Add(myButton);
    myButton.Show();
    myButton.BringToFront();

    Hope this is a good enough example that sets you on your way to create w/e you need
    ClayC

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured