Get an X-size from a Picturebox?

Asked

Viewed 63 times

2

I have a Picture Box, and in some part of the code I edit the horizontal size (x) of it, then further down in the code, I need to edit only the vertical size (y). I want the size of (x) to remain the same as it is currently.

Just one example:

pb->Size = System::Drawing::Size(2, 110 + 8);
pb->Size = System::Drawing::Size(AQUI SERIA ALGO QUE CONTENHA O VALOR ATUAL DE X, 110 + 9);

Or some other alternative to achieve the same result.

Remembering that I want x size and not x location

1 answer

4


You can read the current width through the property Width, thus:

pb->Size = System::Drawing::Size(pb->Size.Width, 110 + 9);

But if you really want to just change the height value, I suggest going directly to change the height value:

pb->Size.Height = 110 + 9;

More details in the documentation: System::Drawing::Size.

  • In . NET In C++ Only "." Is Used for Variables ?

  • If you use -> when the left variable is a pointer, such as pb. But if you use . if it is a direct reference, such as pb->Size. In this respect, C++ is identical to C.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.