c++ cli - Drawing on Form_Load C++/CLI -
i'm drawing on panel method , when call method via button draw, when call method on form_load
doesn't draw anything. when debug it, goes through code without problem, still won't draw anything.
below can see form_load
, button_click
events:
private: system::void selectelementform_load(system::object^ sender, system::eventargs^ e) { if (elementlist->count > 0) { index = 0; drawlinesinlayout(); } }
and button
private: system::void btnleft_click(system::object^ sender, system::eventargs^ e) { if (elementlist->count > 0) { if (index + 1 > 1) { index--; drawlinesinlayout(); } else { index = elementlist->count - 1; drawlinesinlayout(); } } }
when use paint-event
works when form pops up. got code twice in program kinda pointless.
so questions are:
- why isn't form_load using method correctly , button is?
- can call
paint
event on button click?
as hans passant mentioned, can't draw on isn't there yet. solution: draw after created.
invalidate();
doesn't work since there variables change in drawing method (that's why there index
change in each call event).
instead of using load
event, use shown
event. draw lines on form:
private: system::void selectelementform_shown(system::object^ sender, system::eventargs^ e) { if (elementlist->count > 0) { index = 0; drawlinesinlayout(); } }
Comments
Post a Comment