Hi iv been looking everywhere on how to add an instance of a rectangle object when i click a button. I'm using Visual studio2010, there is no sample code on the microsoft website. I've been adding dif code to the event procedure of click for some time now and still no go. this is wat im using now, it compiles without the system.drawing.size(3, 3) line
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Microsoft::VisualBasic::PowerPacks::ShapeContainer^ SCon2;
Microsoft::VisualBasic::PowerPacks::RectangleShape^ thisob;
SCon2->Parent=this;
thisob->Parent = SCon2;
thisob->Location= Point(180, 620);
thisob->CornerRadius = 12;
/* wont let me -> */ thisob->Size =(3, 3);
//set the size
//have tried dif versions of this like..
//thisob->System.Drawing.Size(3, 3);
//and
//thisob->size(3, 3);
cant figure this out... any help would be awesome...
thisob->Size = System::Drawing::Size(3, 3); //<-- Use Scope Resolution Operator
Be careful when usingnamespace(s) in C++/CLI - many of the namespace members are overshadowed by properties of the System::Windows::Forms::Control class, so they'll have to be properly qualified anyway.
i want to plot marks at user determined locations(x,y) to represent cities. i put a bunch of lines on the form to form a grid. Its kind of a makeshift skatter chart. im using rectangles as points.
I just need to add marks at x,y cords on the form i dont care how, whether in a pitcture box, dont know if u can put multiple things in a picture box. i thought the easiest way was to make some objects and set location to the users input.
this seems good for now. it plots the objects like i want. not sure if can erase them
off the map yet. dont know how id do it. thanks fo the input guys now i
figure out how to remove them, and access the container ther in i geuss..
private: System::Void button3_Click_1(System::Object^ sender, System::EventArgs^ e)
{
Microsoft::VisualBasic::PowerPacks::ShapeContainer^ SCon2;
SCon2 = gcnew Microsoft::VisualBasic::PowerPacks::ShapeContainer();
if(gx < 50 || gx >800)
gx = 50;
if(gy < 50 || gy >800)
gy = 50;
for(int i = 0; i < 1; i++, gx+=30, gy+=40)
{
Microsoft::VisualBasic::PowerPacks::RectangleShape^ thisob;
thisob = (gcnew Microsoft::VisualBasic::PowerPacks::RectangleShape());
SCon2->Parent=this;
thisob->Parent = SCon2;
thisob->Size = System::Drawing::Size(3, 3);
thisob->Location= Point(gx, gy);
//thisnegro->Size= Size(3,3);
thisob->CornerRadius = 12;
thisob->BorderColor = Color::Red;
thisob->FillStyle = Microsoft::VisualBasic::PowerPacks::FillStyle::Solid;
thisob->FillColor = Color::Red;
thisob->Visible=true;
thisob->BorderWidth= 2;
}
}