Results 1 to 7 of 7

Thread: Adding buttons at runtime

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2011
    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 2011
    Posts
    8,600

    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 | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    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

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2011
    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 2011
    Posts
    8,600

    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 | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    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

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Dec 2011
    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
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,538

    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 don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * 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??? *

  7. #7
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Adding buttons at runtime

    Moved to the WPF forum.

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