question

Tommyman-5453 avatar image
0 Votes"
Tommyman-5453 asked SimpleSamples edited

User controls in winforms C#

I'm building a simple graphics User Control to plot data in an application. To be able to scale as good as possible i would like the control to determine it's size after layed out on my winform. The controls formpart is used for plotting, and at designtime you can stretch the control area as you wish. Probably there is a simple solution on this , but i have googled a lot and havent found the solution yet. Is that possible, or am i trying to do something foolish?

dotnet-csharpdotnet-runtime
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AndrewFraser-0479 avatar image
1 Vote"
AndrewFraser-0479 answered

Override the OnResize method to get the new size of the control.

Andy

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SimpleSamples avatar image
0 Votes"
SimpleSamples answered SimpleSamples edited

I am not sure what you are asking but perhaps you are looking for ClientSize.Height and ClientSize.Width.

I forget the difference between the Resize Event and the SizeChanged Event but I am nearly certain that the Resize Event fires multiple times during a resize and the SizeChanged Event fires after the resize is complete. You can redraw the user control during the resize or you can wait and resize only once.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.