Autor Beitrag
Kasko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 126
Erhaltene Danke: 1

Win 10
C# C++ (VS 2017/19), (Java, PHP)
BeitragVerfasst: So 06.05.18 21:53 
Hey

Auf meinem Formular habe ich ein Panel mit einer variierenden Anzahl von Buttons. Sie sind alle in einer Reihe angeordnet und sind alle auf dock top festgelegt. Da ich das Design der mitgelieferten Scrollbars und die fehlende Möglichkeit, die Farbe zu ändern, nicht mag, habe ich meine eigene Scrollbar erstellt, die super funktioniert. Das Problem besteht darin, dass AutoScroll auf True festgelegt sein muss, damit es funktioniert. Wenn die summierte Höhe des Inhalts die Höhe des Fensters überschreitet, wird automatisch die Standard-Bildlaufleiste angezeigt, und ich kann sie nicht ausblenden.

Ich habe schon alles probiert

1. Beispiel:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
this.panel_Playlists.AutoScroll = false;
this.panel_Playlists.HorizontalScroll.Enabled = false;
this.panel_Playlists.HorizontalScroll.Visible = false;
this.panel_Playlists.VerticalScroll.Enabled = false;
this.panel_Playlists.VerticalScroll.Visible = false;
this.panel_Playlists.AutoScroll = true;


2. Beispiel:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
public enum ScrollBarDirection
{
    SB_HORZ = 0,
    SB_VERT = 1,
    SB_CTL = 2,
    SB_BOTH = 3
}

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool ShowScrollBar(IntPtr hWnd, int wBar, bool bShow);

protected override void WndProc(ref Message m)
{
    ShowScrollBar(panel_Playlists.Handle, (int)ScrollBarDirection.SB_BOTH, false);
    base.WndProc(ref m);
}


Egal was ich versuche nichts funktioniert. Entweder flackert die Scrollbar oder sie ist dauerhaft zu sehen.

Bitte um schnelle Hilfe.

LG Kasko ;)
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4764
Erhaltene Danke: 1052

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Mo 07.05.18 09:40 
Hallo und :welcome:

solange AutoScroll gesetzt ist, hat man keine Möglichkeit da einzugreifen und die Scrollbars zu verstecken.
Mittels Suche nach "c# auto scroll hide scrollbar" im Internet gibt es eine Reihe von Lösungsvorschlägen (es ist aber nicht ganz so intuitiv - und ich hoffe, du kannst ein wenig englisch):
how to scroll without a scrollbar or make scrollbar invisible
C# WinForms: Make panel scrollbar invisible
Also AutoScroll = false und mittels AutoScrollPosition die Scroll-Position setzen.
Kasko Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 126
Erhaltene Danke: 1

Win 10
C# C++ (VS 2017/19), (Java, PHP)
BeitragVerfasst: Mo 07.05.18 16:03 
Habe bereits in einem englischsprachigen Forum eine Antwort bekommen, welches mir die Nutzung von nested Panels empfohlen hat.

Beispiel

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Panel outerPanel = new Panel();
outerPanel.AutoSize = false;
outerPanel.AutoScroll = false;
// For testing make the bounds very obvious
outerPanel.BackColor = Color.Red;
outerPanel.BorderStyle = BorderStyle.FixedSingle;

Panel innerPanel = new Panel();
innerPanel.Parent = outerPanel;
innerPanel.AutoSize = true;
innerPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
innerPanel.AutoScroll = false;
innerPanel.BorderStyle = BorderStyle.FixedSingle;
innerPanel.BackColor = Color.Blue;

// Scroll down a bit, right a bit
innerPanel.Location = new Point(-50, -30);