Creating a Picturebox at Runtime (windows forms applications)
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: Creating a Picturebox at Runtime (windows forms applications)

  1. #1
    Join Date
    Mar 2009
    Posts
    20

    Exclamation Creating a Picturebox at Runtime (windows forms applications)

    Hi,I want to create a picturebox at runtime.i mean when i click a button then,the picturebox is created.
    i have tried this code, but it doesnt work.

    Code:
                                   
    		                 PictureBox^ pct;
    
                                     pct=gcnew PictureBox;
    				
    				pct->Location = Point(240,210);
    
    				pct->Size.Height= 30;
    
    				pct->Size.Width= 30;
    
    				pct->BackColor.Aquamarine; 
    				 Controls->Add(pct);
    
    				 pct->Visible=true;
    i am using visual c++ 2008.

    after i create a picturebox,i want to create an array of pictureboxes.can anybody please tell me how to create a picturebox and its array.

    Thanks

  2. #2
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: Creating a Picturebox at Runtime (windows forms applications)

    I suggest if you cannot figure out how to properly create a PictureBox then drop one with the designer and look into its code how the designer did it, then try to do the same
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  3. #3
    Join Date
    Mar 2009
    Posts
    20

    Re: Creating a Picturebox at Runtime (windows forms applications)

    i have tried that too...it doesnt work....

  4. #4
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: Creating a Picturebox at Runtime (windows forms applications)

    then could you be more specific about what doesnt work? are there any errors? are those picture boxes not visible? null references or so?
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  5. #5
    Join Date
    Mar 2009
    Posts
    20

    Re: Creating a Picturebox at Runtime (windows forms applications)

    hey,i can make the picture box now.Thanks Anyways.can you please explain how to make an array of objects in windows form?

  6. #6
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: Creating a Picturebox at Runtime (windows forms applications)

    there are many "arrays", the classic one
    Code:
    cli::array
    or .net collections, take a look at this namespace
    Code:
    System.Collections
    and
    Code:
    System.Collections.Generic
    I'm sure you'll find something that suits your needs
    Last edited by memeloo; May 21st, 2009 at 09:01 AM.
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  7. #7
    Join Date
    Mar 2009
    Posts
    20

    Re: Creating a Picturebox at Runtime (windows forms applications)

    hmm...i have no idea what you are talking about,but i will try search.thanks!

  8. #8
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: Creating a Picturebox at Runtime (windows forms applications)

    ...so you'll have to learn some basics first ;]
    Last edited by memeloo; May 21st, 2009 at 09:16 AM.
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  9. #9
    Join Date
    Mar 2009
    Posts
    20

    Re: Creating a Picturebox at Runtime (windows forms applications)

    ya, i need to learn the basics.Our University sucks,they didnt even teach us Programming in GUI and gave us a project to make a Generic Predator/Prey Game.....

  10. #10
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: Creating a Picturebox at Runtime (windows forms applications)

    one of my favourite websites where you can learn something http://functionx.com/cppcli/
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  11. #11
    Join Date
    Mar 2009
    Posts
    20

    Re: Creating a Picturebox at Runtime (windows forms applications)

    yeah its my favorite too!....
    thanks

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center