Hello.
I'm making a winform .NET app. It must show a graphic in bars format. I'm using a picturebox because it's the only way I know how to do it (if someone knows a better way, please tell me).
I'm adding dynamically the lines (the bars of the graphic) with this code:
int currentX = this.lineAmmount * (lineWidth + lineMargin);
pictureBox.CreateGraphics().DrawLine(new Pen(color, lineWidth), //Pen
currentX, pictureBox.Height, //Starting (x, y)
currentX, pictureBox.Height - Convert.ToInt32(value * graphicsScale)); //Ending (x, y)
this.lineAmmount++;
That works just perfect.
What I want now is the pictureBox to have an horizontal scroll bar. So what I put the pictureBox into a panel with autoscroll = true. Now what I needed its to dynamically increase the pictureBox width. So I added this code after I add each line:
pictureBox.Width = Math.Max(this.lineAmmount * (lineWidth + lineMargin), 205);
(205 is the minimum width I want).
That code also works greate. The width is increased. With the first lines Math.Max always returns 205, after a couple of lines it starts returning the orher value. From that moment on ALL THE LINES DISAPPEAR!!!
Please help!!
Thanks in advance and sorry for my bad english,
Diego