valeriy_zf 0 Newbie Poster

How to assign the graphic object (Line, Rectangle, Ellipse) to the Form?

Lets see this example:

I created the Line object somewhere in the program:

namespace TEST_Graf {
	using namespace System::Windows::Forms;
       // this code requires links to: PresentationCore, PresentationFramework, WindowsBase
	using namespace System::Windows::Controls;
	using namespace System::Windows::Shapes;
	using namespace System::Threading;
	public ref class Form1 : public System::Windows::Forms::Form
	{
       // Form1 class declaration....
 //------------------------------------------------------------------------------------------
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
	       Line^ myLine = gcnew Line();
               myLine->X1 = 1;
               myLine->X2 = 50;
               myLine->Y1 = 1;
               myLine->Y2 = 50;
            // And here I'd like to assign the line "myLine" to the Form1
           // I just want to see this line on the Form1
       }

The next code is working properly:

using namespace System::Windows;
//------------------------------------------------------------------------------------------
               // Create the application's main window
               Window^ myWindow = gcnew Window();
               myWindow->Content = myLine;
 //-----------------------------------------------------------------------------------

But I want to see myLine on the Form1 (I do not need the empty Window).

Thank you!

---------------
Visual C++ 2008

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.