Autor Beitrag
Chiyoko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 298
Erhaltene Danke: 8

Win 98, Win Xp, Win 10
C# / C (VS 2019)
BeitragVerfasst: Sa 30.04.11 03:39 
Huhu,

ich habe ein komisches Problem, das schlecht zu beschreiben ist:

Nehmen wir an, ich habe ein Panel, autoscroll ist aktiv.
Jetzt erstelle ich zur Laufzeit mehrere Textboxen und Label,
die ich durch den Index eines Treeview items durchschalten kann.

Als Beispiel Index 1 und Index 2.

Index 1, Textboxen werden erstellt.
Scrollbalken horizontal sind zu sehen.
Ich scrolle nun 2000 Pixel nach unten,da wo auch die textbox endet.

Nun schalte ich per Index 2 um, der Inhalt des Panels wird geelöscht.
Der Inhalt von index 2 ist nun sichtbar.
Jetzt habe ich aber oberhalb und unterhalb zuviel freien Platz im Panel.
Irgendwas stimmt da nicht und ich wüsste gerne was.

Bei der Erstellung verwende ich SuspendLayout und ResumeLayout(false),
konnte aber nicht feststellen, ob es damit zusammenhaengt.

D.h. zusammenfassend:
Statt einer Clientgrösse von vielleicht 1500 Pixel addieren sich nun oberhalb
und unterhalb der Steuerelemente weitere 4000 dazu(als Beispiel).

Wie kann ich das beheben?
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4796
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Sa 30.04.11 10:28 
Hallo Chiyoko,

wenn du zur Laufzeit Controls innerhalb eines ScrollableContainers (z.B. Panel) erstellst, so beziehen sich die Positionsangaben immer relativ zur aktuellen ScrollPosition (nicht zur (0,0)-Position des Panels). Du mußt daher immer noch die ScrollableControl.AutoScrollPosition-Eigenschaft dazuaddieren (da diese Werte negativ sind), d.h.:
ausblenden C#-Quelltext
1:
control.Location = new Point(x + panel1.AutoScrollPosition.X, y + panel1.AutoScrollPosition.Y);					
Chiyoko Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 298
Erhaltene Danke: 8

Win 98, Win Xp, Win 10
C# / C (VS 2019)
BeitragVerfasst: Sa 30.04.11 11:45 
Au ja, der Tip ist klasse, funktioniert einwandfrei.
Danke dir vielmals.