|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Passing the name of a component and use it to do something to that componentHi,
I have an form with 64 picture boxes named pic1 ... pic64. Then I have a procedure which create a bitmap filled with red and then I place it in the PictureContainer. Now I would like to know if it is possible to pass to this procedure name of the picture box in which to place the bitmap Example (this does not work) string sTxt = "pic1"; Bitmap bmp1 = new Bitmap(32,32); (PictureBox)sTxt.Image=bmp1; <<Error Here Any idea if it is possible to achieve this. Regards Ivan Sammut hi,
Each control has a Name property, you can search the Controls collection for the correct Name value. foreach( Control control in Controls) if ( control.Name == theName ) ( (PictureBox)control).Image = bmp1; cheers, -- Show quoteIgnacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation "Ivan Sammut" <samm***@hotmail.com> wrote in message news:uj7HFYTMFHA.2704@TK2MSFTNGP15.phx.gbl... > Hi, > > I have an form with 64 picture boxes named pic1 ... pic64. > > Then I have a procedure which create a bitmap filled with red and then I > place it in the PictureContainer. Now I would like to know if it is > possible > to pass to this procedure name of the picture box in which to place the > bitmap > > Example (this does not work) > string sTxt = "pic1"; > Bitmap bmp1 = new Bitmap(32,32); > (PictureBox)sTxt.Image=bmp1; <<Error Here > > Any idea if it is possible to achieve this. > > Regards > Ivan Sammut > > >
Other interesting topics
|
|||||||||||||||||||||||