Hi,
I have a panel which i draw something..
This is a part of my code(You dont need to read all code, i just wanted to show how it looks like):
Dim g As Graphics = msjscrlist.Item(sender.tag).Controls("Powner").Controls("P").CreateGraphics
for i=0 to ......
code...
for k=0 to ......
code...
msjcount += 1
linecount = 1
If g.MeasureString(ben, New Font("tahoma", 8)).Width > msjscrlist.Item(sender.tag).Controls("Powner").Controls("P").Width - 10 Then
linecount = Math.Ceiling(g.MeasureString(ben, New Font("tahoma", 8)).Width / msjscrlist.Item(sender.tag).Controls("Powner").Controls("P").Width - 10)
End If
If itsme = True Then
g.FillRectangle(New SolidBrush(Color.Green), msjscrlist.Item(sender.tag).Width - g.MeasureString(ben, New Font("tahoma", 8)).Width - 20, sonalt + 8, g.MeasureString(ben, New Font("tahoma", 8)).Width + 20, linecount * 28)
g.DrawString(ben, New Font("Tahoma", 8), Brushes.White, New Point(msjscrlist.Item(sender.tag).Width - g.MeasureString(ben, New Font("tahoma", 8)).Width - 10, sonalt + 16))
sonalt += 8 + linecount * 28
ben = Nothing
Else
g.FillRectangle(New SolidBrush(Color.Teal), 0, sonalt + 8, g.MeasureString(hedef, New Font("tahoma", 8)).Width + 20, linecount * 28)
g.DrawString(hedef, New Font("Tahoma", 8), Brushes.White, New Point(10, sonalt + 16))
sonalt += 8 + linecount * 28
hedef = Nothing
End If
next
code...
next
The problem is; graphics that i draw are disappearing when i scroll the panel, how can i make those graphics persistent? People say: do drawing in 'onpaint' event. But i have a long code, wouldn't it be slow?