Hello CSharpCorner
I'm working on a paintapplication working with GDI+ in C# and i have a little problem.
In my first step i want to draw a simple line in A PANEL.
There are many tutorials that explain how it works on the form itself but it's quite important for my project it's in a panel.
Even when i put the code to draw on the form itself it gives a error.
With what code can i simply draw this line on a panel?
greetz
Loading
GuanPosted Aug 25, 2010, 8:04 AM
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
}
The error list says this:
Error 1 'WindowsFormsApplication1.Form1' does not contain a definition for 'Form1_Paint' and no extension method 'Form1_Paint' accepting a first argument of type 'WindowsFormsApplication1.Form1' could be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs 52 75 WindowsFormsApplication1
Why is that ? That constructor isn't used anywhere to paint on it and i don't use that constructor anywhere. To get my default form this code is enough i think ?
private void Form1_Load(object sender, EventArgs e)
{
}
Gomathi PalaniswamyPosted Aug 25, 2010, 6:55 AM
Is it showing error in designer code?
With regards,
Gomathi.P
GuanPosted Aug 25, 2010, 5:40 AM
Thanx for your help.
When i try it, it works fine like i want, but i have a question.
When i succeeded to draw my line on the form itself i wrote down my code between this constructor
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
}
When i use my panel now, i think it's logical i write it between this constructor
private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
}
Everything works as long as i don't clear the first constructor (form1_paint)
When i delete that one, Visual Studio gives me an error. Why is that?
I think that constructor isn't necessary anymore or am i wrong ?
Greetings
Guan
Gomathi PalaniswamyPosted Aug 25, 2010, 12:55 AM
create the graphics on panel.(i.e) panel.creategraphics();
With Regards,
Gomathi.P