2010-06-03 5 views
0

J'ai un panneau et en ce qu'un contrôle devrait être ajouté sur le panneau cliquez sur le bouton dans ce contrôle .. J'ai amarré ces contrôles au fond puisque j'ai un autre contrôle qui doit être au sommet toujours .. Maintenant, le problème est, Je définis une taille maximale de sorte que, après que la taille maximale est atteinte, le défilement automatique du panneau devrait entrer, et l'exigence est comme lorsqu'un contrôle est ajouté, faites défiler vers le bas jusqu'au dernier contrôle ajouté. . Je ne sais pas comment atteindre cette exigence ...problème d'auto-défilement

Modifier

Ce code sur le bouton de contrôle ... Cliquez

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(); 

Et cela pour placer les commandes en conséquence sur le panneau:

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); 

Le searchCriterionControl est le contrôle qui est ajouté au panneau .. Comme je l'ai dit ci-dessus le searchCriterionControl a un bouton sur le clic de celui-ci searchCriterionControl devrait ajouter sur le panneau ... Et SearchCriterionControl est ancré au fond depuis, this.expanderWithLabelSearch contrôle est ancré au sommet du panneau.

+0

S'il vous plaît poster un code pour montrer ce que vous avez. – JYelton

+0

ce code sur le bouton de contrôle cliquez sur ... 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.Hauteur) + SearchCriteriaControl.MARGIN * 2); this.SuspendLayout(); this.pnlSearchItems.Controls.Add (contrôle); this.ResumeLayout (faux); \t \t \t \t this.PerformLayout(); control.Focus(); – curiosity

+0

Et ceci pour placer les contrôles en conséquence sur le panneau, this.pnlSearchItems.AutoScroll = false; this.pnlSearchItems.Height = this.expanderWithLabelSearch.Hauteur + (numberOfControls) * this.searchCritenControl.Height + SearchCriteriaControl.MARGIN * 2; this.tlpSearchBy.Height = this.pnlSearchItems.Height; this.Height = this.pnlSearchItems.Height + son.pnlGroupItems.Height + this.pnlControls.Height + SearchCriteriaControl.MARGIN * 4; this.tblGroupBy.Location = nouveau point (SearchCriteriaControl.STARTWIDTH, this.pnlSearchItems.Height + SearchCriteriaControl.MARGIN * 2); – curiosity

Répondre

2

Si pnlSearchItems est le panneau qui doit faire défiler, vous devriez regarder:

.ScrollControlIntoView(Control)

Notez que le panneau doit avoir AutoScroll à true.

+0

oui j'ai essayé ça aussi ... mais ça ne marche pas :( – curiosity