2010-06-03 52 views
0

我有一個面板,並在該控制按鈕應該在面板上點擊添加控件.. 我將這些控件停靠在底部,因爲我有另一個控件必須始終在頂部.. 現在的問題是,我設置了一個maxsize,以便在達到最大大小後面板的自動滾動應該啓動,並且需求如添加控件時的,滾動應滑動到最新添加的控件。 。 我不知道該如何實現這一要求......autoscroll問題

編輯

此代碼上的控制按鈕,點擊...

SearchCriterionControl control = new SearchCriterionControl(); 
control.SupportedMetaDataItems = this.supportedSearchParams; 
control.AddOrRemoveButtonClick += new EventHandler(AddOrRemoveSearchItemsButtonClick); 
control.Location = new Point(SearchCriteriaControl.STARTWIDTH, this.searchCritenControl.Height * (this.pnlSearchItems.Controls.Count - 1) + (this.expanderWithLabelSearch.Height) + SearchCriteriaControl.MARGIN * 2); 
this.SuspendLayout(); 
this.pnlSearchItems.Controls.Add(control); 
this.ResumeLayout(false); 
this.PerformLayout(); 
control.Focus(); 

而這相應地將面板上的控件:

this.pnlSearchItems.AutoScroll = false; 
this.pnlSearchItems.Height = this.expanderWithLabelSearch.Height + (numberOfControls) * this.searchCritenControl.Height + SearchCriteriaControl.MARGIN * 2; 
this.tlpSearchBy.Height = this.pnlSearchItems.Height; 
this.Height = this.pnlSearchItems.Height + his.pnlGroupItems.Height + this.pnlControls.Height + SearchCriteriaControl.MARGIN * 4; 
this.tblGroupBy.Location = new Point(SearchCriteriaControl.STARTWIDTH, this.pnlSearchItems.Height + SearchCriteriaControl.MARGIN * 2); 
this.pnlControls.Location = new Point(SearchCriteriaControl.STARTWIDTH, this.pnlSearchItems.Height + this.pnlGroupItems.Height + SearchCriteriaControl.MARGIN * 2); 

searchCriterionControl是被添加到面板控制.. 。正如我上面所說的searchCriterionControl有一個按鈕上的另一個searchCriterionControl應該添加在面板上...而SearchCriterionControl停靠在底部,因爲this.expanderWithLabelSearch控制停靠在面板的頂部。

+0

請張貼一些代碼,以顯示您正在進行的操作。 – JYelton 2010-06-03 16:06:01

+0

這個代碼在控件按鈕上點擊... SearchCriterionControl control = new SearchCriterionControl(); control.SupportedMetaDataItems = this.supportedSearchParams; control.AddOrRemoveButtonClick + = new EventHandler(AddOrRemoveSearchItemsButtonClick); control.Location = new Point(SearchCriteriaControl.STARTWIDTH,this.searchCritenControl.Height *(this.pnlSearchItems.Controls.Count - 1)+(this.expanderWithLabelSearch.Height)+ SearchCriteriaControl.MARGIN * 2); this.SuspendLayout(); this.pnlSearchItems.Controls.Add(control); this.ResumeLayout(false); \t \t \t \t this.PerformLayout(); control.Focus(); – curiosity 2010-06-03 16:14:43

+0

並將此控件放置在面板上, this.pnlSearchItems.AutoScroll = false; this.pnlSearchItems.Height = this.expanderWithLabelSearch.Height +(numberOfControls)* this.searchCritenControl.Height + SearchCriteriaControl.MARGIN * 2; this.tlpSearchBy.Height = this.pnlSearchItems.Height; this.Height = this.pnlSearchItems.Height + his.pnlGroupItems.Height + this.pnlControls.Height + SearchCriteriaControl.MARGIN * 4; this.tblGroupBy.Location = new Point(SearchCriteriaControl.STARTWIDTH,this.pnlSearchItems.Height + SearchCriteriaControl.MARGIN * 2); – curiosity 2010-06-03 16:17:15

回答

2

如果pnlSearchItems是應該滾動面板,你應該看看:

.ScrollControlIntoView(Control)

此外,面板必須自動滾屏設置爲true。

+0

是的,我也嘗試過...但這不工作:( – curiosity 2010-06-04 03:47:16