Calling a RedrawLines() method in the Paint Event that was effective but I made some minor changes that should have had no effect and now I'm having issues. First of all, when I switch tabs, each of which contain my UserControl, the lines are not redrawing as they did before. Furthermore, when I use the MouseWheel, the lines are not drawn entirely, as in they are cut off at the top and bottom of the UserControl. Yet, when I use the ScrollBar, they are drawn in their entirety. Any idea?
Here is part of my DrawLine() method after getting the points necessary:
System.Drawing.Pen myPen;
myPen = new System.Drawing.Pen(Color.Black);
myPen.Width = 3;
System.Drawing.Graphics formGraphics = this.CreateGraphics();
formGraphics.DrawLine(myPen, p1.X, p1.Y, p2.X, p2.Y);
myPen.Dispose();
formGraphics.Dispose();
so then I have a RedrawLines method that calls this accurately
private void RedrawLines(){
Graphics g = Graphics.FromHwnd(this.Handle);
g.Clear(Color.White);
g.Dispose();
for (int i =0; i < Set_Of_Connections.Count; i++)
{
DrawLine(Set_Of_Connections[i].ins.cb, Set_Of_Connections[i].outs.cb, Color.Green);
}
}
call this in the Paint Event:
private void Switch_Paint(object sender, PaintEventArgs e)
{
RedrawLines();
}
But like I said this probably isn't going to help you at all.