CLR,How to modify the AutoScrollMinSize of Form1 by coding? [modified]
-
I want to modify the AutoScrollMinSize of Form1 by the code as below:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
this->AutoScrollMinSize.Width=1000;
this->AutoScrollMinSize.Height=1000;
}But it still not be active. Could somebody know how to modify the AutoScrollMinSize of Form1? PS:already set Form1's AutoScroll as True.
modified on Tuesday, November 17, 2009 3:24 AM
-
I want to modify the AutoScrollMinSize of Form1 by the code as below:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
this->AutoScrollMinSize.Width=1000;
this->AutoScrollMinSize.Height=1000;
}But it still not be active. Could somebody know how to modify the AutoScrollMinSize of Form1? PS:already set Form1's AutoScroll as True.
modified on Tuesday, November 17, 2009 3:24 AM
a Size is a struct, hence a value type; you can't just modify part of it to modify the object. Assign a new Size with the width AND height you want. :)
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
I want to modify the AutoScrollMinSize of Form1 by the code as below:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
this->AutoScrollMinSize.Width=1000;
this->AutoScrollMinSize.Height=1000;
}But it still not be active. Could somebody know how to modify the AutoScrollMinSize of Form1? PS:already set Form1's AutoScroll as True.
modified on Tuesday, November 17, 2009 3:24 AM
Size is a struct, so when you directly modify its properties, you are actually modifying a copy of it. (Actually modifying two copies of it in your code, one for width and another for height :)). Use something like this:
this->AutoScrollMinSize = gcnew Size(1000,1000);