Results 1 to 7 of 7

Thread: Adding buttons at runtime

  1. #1
    Addicted Member
    Join Date
    Dec 11
    Posts
    176

    Adding buttons at runtime

    Hey, im just wondering if i can make a user control in Expression blend (a button) and add it to my form dynamically at runtime but with changes such as the button.content.

    Thanks, Tim

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 11
    Posts
    3,143

    Re: Adding buttons at runtime

    I don't know what Expression blend is but you can create any control dynamically and add it to a container like a Form or GroupBox at runtime by using the container's Controls property.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | Create Sortable BindingList(not mine) | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading


    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

  3. #3
    Addicted Member
    Join Date
    Dec 11
    Posts
    176

    Re: Adding buttons at runtime

    Expression Blend is just a nice program that helps you design better WPF applications then visual studio.
    I was going to add the buttons to a panel but im not sure what you mean by the container's Controls property.

    Thanks, Tim

  4. #4
    Angel of Code Niya's Avatar
    Join Date
    Nov 11
    Posts
    3,143

    Re: Adding buttons at runtime

    Unfortunately, I don't know anything about WPF. Windows Forms have a Controls property which is basically a collection that works like any collection. You can add, remove and clear stuff from it. As a matter of fact, all controls in a Windows Forms application have such a property.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | Create Sortable BindingList(not mine) | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading


    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

  5. #5
    Addicted Member
    Join Date
    Dec 11
    Posts
    176

    Re: Adding buttons at runtime

    Yes i now understand i can add buttons dynamically like this
    Dim btn As New Button
    Controls.Add(btn)
    however i want to add custom buttons i have made in expression blend in the same way i did a default button above.
    i dont know if it helps but the button i made in expression blend opens in visual studio as file called "newbutton.xaml"

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 02
    Posts
    21,659

    Re: Adding buttons at runtime

    This should actually be in the WPF section... I'll ask a mod to move it...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    *Proof positive that searching the forums does work: View Thread *
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *
    * Use Offensive Programming, not Defensive Programming. * On Error Resume Next is error ignoring, not error handling(tm).
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN

  7. #7
    Super Moderator Joacim Andersson's Avatar
    Join Date
    Jan 99
    Location
    Sweden
    Posts
    13,440

    Re: Adding buttons at runtime

    Moved to the WPF forum.
    Joacim Andersson
    Microsoft MVP, MCSD, MCSE, Sun Certified Java Programmer
    If anyone's answer has helped you, please show your appreciation by rating that answer.
    I'd rather run ScriptBrix...
    Joacim's view on stuff.

Posting Permissions

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