I am new with using graphics and I am trying to draw a filled rectangle when the form opens.. but nothing is working and do not know the reason
here is my code :
Generic Heart rate Sensor
where Result is my form that is supposed I draw the rectangle on when it is loaded
but when I load the form nothing happens at all
where the problem ?
thanks in advance
答案 0 :(得分:2)
Add handler to +
event in form's constructor:
(function () {
var debug = false
if (debug === false) {
if ( typeof(window.console) === 'undefined') { window.console = {}; }
window.console.log = function () {};
}
})()
And create method frmMain_Paint:
Paint
Tips
/// <summary>
/// form constructor
/// </summary>
public frmMain()
{
InitializeComponent();
this.Paint += frmMain_Paint;
}
)void frmMain_Paint(object sender, PaintEventArgs e)
{
using (System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Green))
{
e.Graphics.FillRectangle(myBrush, new Rectangle(0, 0, 200, 300));
}
}
keyword as in example above.