any appreciated. how create colored dot on panel on user clicks mouse? can coordinates of mouse click , output through message box can't draw dot on panel user clicked. have these codes tried.
private sub createdot(x, y) msgbox(x & " " & y) dim mygraphics graphics = me.creategraphics dim mypen pen mypen = new pen(drawing.color.maroon, 20) mygraphics.drawrectangle(mypen, x, y, 1, 1) end sub private sub panel1_mouseclick(sender object, e system.windows.forms.mouseeventargs) handles panel1.mouseclick missed += 1 lblmissed.text = missed dim x, y integer x = e.x.tostring y = e.y.tostring createdot(x, y) end sub
thanks!
three things:
1.if draw on panel should use panel1.creategraphics not me.creategraphics
2.the width of pen large dot. use 1 instead
3.do not convert x, y strings , pass createdot
caution:
panel invalidated (for example move window on it) dot disappear. drawing code should in panel1_paint event` (scott chamberlain)
private sub createdot(byval x integer, byval y integer) msgbox(x.tostring & " " & y.tostring) dim mygraphics graphics = panel.creategraphics dim mypen pen mypen = new pen(drawing.color.maroon, 1) mygraphics.drawrectangle(mypen, x, y, 1, 1) end sub private sub panel1_mouseclick(sender object, e system.windows.forms.mouseeventargs) handles panel1.mouseclick missed += 1 lblmissed.text = missed createdot(e.x, e.y) end sub