Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Initialize Fields

Status
Not open for further replies.

RoguePoet01

Programmer
Oct 1, 2003
302
US
Hi,

I'm trying to initialize a picture box to equal the height and width of the form, but I keep getting an error.


Here is the code:

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

pb1.Size.Width = this.Size.Width;
pb1.Size.Height = this.Size.Height;

}



Here is the error:

Cannot modify the return value of 'System.Windows.Forms.Control.Size' because it is not a variable

I'm stumped, because if height and width isn't a variable, what the heck is it?
 
The Size is a class value like a Structure in C and you have to create a new Size object and after that set the Size propoerty of the picturebox:
Size sz= new Size();
sz.Width=this.Size.Width;
sz.Hight = this.Size.Height;
pb1.Size = sz;

-obislavu-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top