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
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
Re: Creating a Picturebox at Runtime (windows forms applications)
i have tried that too...it doesnt work....:(
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?
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?
Re: Creating a Picturebox at Runtime (windows forms applications)
there are many "arrays", the classic one or .net collections, take a look at this namespace and
Code:
System.Collections.Generic
I'm sure you'll find something that suits your needs
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!
Re: Creating a Picturebox at Runtime (windows forms applications)
...so you'll have to learn some basics first ;]
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.....
Re: Creating a Picturebox at Runtime (windows forms applications)
one of my favourite websites where you can learn something http://functionx.com/cppcli/
Re: Creating a Picturebox at Runtime (windows forms applications)
yeah its my favorite too!....
thanks