-
here's what the code is telling me:
1) backg is initialized to a Bitmap that is independent from everything else.
2) temp is initialized to draw onto Panel2's graphics.
3) updatemap() draws what you want to temp, which is pointing to Panel2's graphics object.
4) painthandler() draws backg...which at this point is still a blank Bitmap
it should work if you use the temp = ...CreateGraphics() instead.
-
temp is a creategraphics()
Code:
backg = new Bitmap(splitContainer1.Panel2.Width, splitContainer1.Panel2.Height);
temp = splitContainer1.Panel2.CreateGraphics();
//temp = Graphics.FromImage(backg);
when i run it - the grid is initially drawn to the panel2 on the paint event but only after i have clicked on the panel. when i drag on the panel it draws the rectangle but does not clear it so i get consecutive rectangles where i didnt before, it also fills the area i have dragged as it is supposed to. also if i click the panel it draws the tile it is supposed to but wont erase it on a right click where it did before.
i suspect this is because - as you mentioned - i was recreating the bitmap on every call to the update routine also which would explain the rectangle clearing as well as everything else working properly.
EDIT:
after looking into this today i have found some information which implies that the double buffer for the main form WILL NOT affect the panel, only the main form. However if you try to set his on the form you get a IDE error about not being able to do it. It appears you have to derive from Panel and set it in there - however this is way above what i know at the moment so any suggestions on how i can do this may help.
like everything is this taking longer to implement than i thought but hey im learnings more and if everything went right it wouldnt be interesting :)
-
sorry, i meant use temp = Graphics.FromImage(); that way you are manually creating your own bitmap, and linking your own graphics object to that bitmap, and when you're ready to draw it onto the panel or form, you use the DrawImage method.
-
thanks for all your help bling - but i conceded to the fact that using the splitcontainerpanel was not going to make it easier ( as originally thought) so reverted to a single panel and a picturebox. this took about 20 minutes to integrate into existing code and now works perfectly.
the problem with the splitcontrolpanel was that everything i looked at that covered the topic was deriving a panel from its base which i do not want to delve into just yet.
i have found a program which appears to use the splitcontainermpanel method but i have yet to go through tthe source to see if he overrides any of the paint methods or hooks into them. when i get a minute and i dont forget i will tryto debug his code and see how he does it.
thanks for the info along the way and you have definately made me aware of a few things i didnt realise. so once again a big thankyou.
ill be back - :)
-