B
Bradford
I have an Windows application that displays lots of different colored lines in a Panel by using the Graphics.DrawLine method. The location and length of each line comes from a database query that takes two minutes to complete.
I am using the Panel's Paint event to call my drawing method, which accepts PaintEventArgs as a parameter. The problem is that every time the Window is moved or hidden, it needs to be repainted, which takes a long time because the database is queried every time.
To avoid this, I thought that I would try to create a bitmap programmatically from the query in the Form's Load event, and load that into the panel whenever it is painted/repainted in order to prevent unnecessary requerying of the database. I don't know if this is a good solution and I don't know how exactly to go about it. Should I save the queried data to a Stream, or directly to a Bitmap? Can anyone point me in the right direction?
Bradford
I am using the Panel's Paint event to call my drawing method, which accepts PaintEventArgs as a parameter. The problem is that every time the Window is moved or hidden, it needs to be repainted, which takes a long time because the database is queried every time.
To avoid this, I thought that I would try to create a bitmap programmatically from the query in the Form's Load event, and load that into the panel whenever it is painted/repainted in order to prevent unnecessary requerying of the database. I don't know if this is a good solution and I don't know how exactly to go about it. Should I save the queried data to a Stream, or directly to a Bitmap? Can anyone point me in the right direction?
Bradford