我想要調整Windows窗體上的UserControl(它有一個網格)。 下面的代碼是我在表單中的內容。我得到的行爲是,當我把它變大的時候,控件被調整大小。但它不縮水。我在做什麼錯(或)我錯過了什麼?不能修改表達式,因爲它不是一個變量
private void AdjustGrid()
{
ZoomControl.Location = new Point(5, 5);
ZoomControl.Size = new Size(this.Width - 15, this.Height - 75);
}
void zoomform_Resize(object sender, EventArgs e)
{
AdjustGrid();
}
現在用戶控件具有以下代碼:
//Resize the grid that the UserControl has on it
private void NameValuePropertyBag_Resize(object sender, EventArgs e)
{
grdNameValueProperties.Location = new Point(4,4);
grdNameValueProperties.Size = new Size(this.Width - 8, this.Height - 8);
}
我試圖
grdNameValueProperties.Size.Width = this.Width - 8;
grdNameValueProperties.Size.Height = this.Height -8;
它使我的錯誤 「因爲它不是一個變量不能修改的表達」。 ..我錯過了什麼?
附加信息:
我使用的setparent()調用的Windows移動/縮放一個用戶控件爲另一種形式(ZoomForm)。
Anchor似乎不適用於使用SetParent()移動的控件......更確切地說,它可能正在工作,但我已經重新繪製問題。
我錨/碼頭對無需重繪問題的工作[我刪除調整大小事件wireup和調整停靠到填充]
的ZoomForm initally沒有控制。 Usercontrol被動態添加到ParentForm中。
目前,我可以使縮放表格更大
與上述代碼
但不小於。
爲什麼不使用錨定屬性而不是代碼來調整大小? – recursive 2009-04-15 00:38:50
@recursive:我使用SetParent()Windows調用來移動/縮放UserControl到另一個窗體(ZoomForm)。 Anchor似乎並不適用於使用SetParent()移動的控件...更確切地說,它可能正在工作,但我已經重繪問題 – 2009-04-15 00:47:36