我有一个面板,在该控件中的按钮的面板上应该添加一个控件。我把这些控件停靠在底部,因为我有另一个必须一直在顶部的控件.现在的问题是,我设置了一个maxsize,这样在达到maxsize之后,面板的自动滚动框应该启动,并且要求类似于添加控件时的,滚动应该滑到最新添加的控件.我不知道如何实现该要求.
编辑
此代码在“控件”按钮上单击..。
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控件被停靠在面板的顶部。
发布于 2010-06-03 16:31:31
如果pnlSearchItems是应该滚动的面板,则应该查看:
.ScrollControlIntoView(Control)
注意,面板必须将AutoScroll设置为true。
https://stackoverflow.com/questions/2967689
复制相似问题