c# - WinForms Graphics PictureBox with dynamic width -


I'm making a winform .NET app it should show graphic in bar format. I am using a picturebox because this is the only way I know how to do it (if someone knows better, please let me know).

I'm dynamically adding lines (graphic bars) with this code:

  int currentX = this.lineAmmount * (Linewid + LineMargin); Dotline (new pen (color, linewidth), // pen current x, picture box.height, // start (x, y) current x, picture box .high - convert toint32 (value * graphics scale); // ending (x, y) this.lineAmount ++;  

This works perfectly.

Now I want the picture box to have a horizontal scroll bar, so I put the picture box in a panel with autoscroll = true. Now what was the need for it to increase the width of the picture box dynamically? So I added this code after adding each line:

  picturebox.Width = Math.Max ​​(this.lineAmount * (Linewid + LineMargin), 205);  

(205 minimum width I want).

This code also works greate width increases. Mathematics with first line.Max always gives 205, after some lines it starts returning to other values.

Please help !!

Thanks in advance and sorry for my bad english,

Diego

I found out the chart control that it does all automatically.


Comments