Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Please correct if I am wrong in Design or suggest me to go through right way..

I have created one small assignment. and i need your suggestions to work that application.

As my previous mfc code was unmanaged and thinking the same way,
so I m getting little confused to work with managed c# code.


Contents are

Mainform class:- which runs through main application which contains 2 panels.

Global class:-
DrawShape(Line object, Graphics gObject)
{
  object.Draw(gObject);
}


Line class:-
public void Draw(Graphics object);


Form1 class:- Its independent form. contains one button

On button Click()
	{
	Line object = new Line();
			
  	          //TODO:
		
		  //I want to draw the line on mainform's panel for
                  //that i need Graphics object of Mainform.panel.
			
		  // Global.DrawShape(object, GraphicsObject);
		}
Posted
Updated 29-Dec-09 21:06pm
v4

You should handle the panel's Paint event and perform your drawing there. PainEventArgs offers graphics object as one of its property. That will have method for drawing lines on it.

In the button click event, you can set the values which you need and then create the line.
 
Share this answer
 
Thanks,

I have used Event handling and it worked. but It throws Cross thread operation invalid error.
I solved it using invoke method but i didn't understand what is Cross thread operation.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900