Move The Vertical Scroll Bar of a Scroll Panel to The Left Side

Move the vertical scroll bar of a scroll panel to the left side

You could

  • create a ScrollBar
  • bind the ScrollBar properties to the relevant properties of the ScrollPane
  • hide the ScrollBars of the ScrollPane

Here's a quick draft:

ExternalScrollbar.java

import javafx.application.Application;
import javafx.geometry.Orientation;
import javafx.scene.Scene;
import javafx.scene.control.ScrollBar;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.shape.Line;
import javafx.stage.Stage;

public class ExternalScrollbar extends Application {

@Override
public void start(Stage stage) {

Pane pane = new Pane();
Line line = new Line(100, 100, 1000, 1000);
pane.getChildren().add(line);

ScrollPane scrollPane = new ScrollPane();
scrollPane.setContent(pane);

ScrollBar vScrollBar = new ScrollBar();
vScrollBar.setOrientation(Orientation.VERTICAL);
vScrollBar.minProperty().bind(scrollPane.vminProperty());
vScrollBar.maxProperty().bind(scrollPane.vmaxProperty());
vScrollBar.visibleAmountProperty().bind(scrollPane.heightProperty().divide(pane.heightProperty()));
scrollPane.vvalueProperty().bindBidirectional(vScrollBar.valueProperty());

ScrollBar hScrollBar = new ScrollBar();
hScrollBar.setOrientation(Orientation.HORIZONTAL);
hScrollBar.minProperty().bind(scrollPane.hminProperty());
hScrollBar.maxProperty().bind(scrollPane.hmaxProperty());
hScrollBar.visibleAmountProperty().bind(scrollPane.widthProperty().divide(pane.heightProperty()));
scrollPane.hvalueProperty().bindBidirectional(hScrollBar.valueProperty());

// hide scrollpane scrollbars
// TODO: re-activate the code
// scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
// scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
// scrollPane.setPadding(Insets.EMPTY);

HBox hBox = new HBox();
HBox.setHgrow(scrollPane, Priority.ALWAYS);
hBox.getChildren().addAll(vScrollBar, scrollPane);

VBox vBox = new VBox();
VBox.setVgrow(hBox, Priority.ALWAYS);
vBox.getChildren().addAll(hScrollBar, hBox);

Scene scene = new Scene(vBox, 500, 400);
scene.getStylesheets().add(this.getClass().getResource("style.css").toExternalForm());

stage.setScene(scene);
stage.show();

vScrollBar.requestLayout();
hScrollBar.requestLayout();
}

public static void main(String[] args) {
launch(args);
}
}

style.css

.scroll-pane {
-fx-background-insets: 0;
-fx-padding: 0;
}

.scroll-pane:focused {
-fx-background-insets: 0;
}

.scroll-pane .corner {
-fx-background-insets: 0;
}

Of course you have to activate the code with the hiding of the ScrollBars of the ScrollPane.

Sample Image

How to position a div scrollbar on the left hand side?

  .list_container {
direction: rtl;
overflow:auto;
height: 50px;
width: 50px;
}

.item_direction {
direction:ltr;
}
<div class="list_container">
<div class="item_direction">1</div>
<div class="item_direction">2</div>
<div class="item_direction">3</div>
<div class="item_direction">4</div>
<div class="item_direction">5</div>
<div class="item_direction">6</div>
<div class="item_direction">7</div>
<div class="item_direction">8</div>
<div class="item_direction">9</div>
<div class="item_direction">10</div>
<div class="item_direction">11</div>
<div class="item_direction">12</div>
</div>

DIV Vertical Scroll bar on left

You can add a pseudo-scrollbar anywhere you want with JQuery and this plug-in: JScrollPane

C#/winforms Panel with vertical scrollbar on left?

If you add WS_EX_LEFTSCROLLBAR extended style to the control it shows scrollbar on left side:

using System.Windows.Forms;
public class ExPanel : Panel
{
private const int WS_EX_LEFTSCROLLBAR = 0x00004000;
protected override CreateParams CreateParams
{
get
{
var cp = base.CreateParams;
cp.ExStyle = cp.ExStyle | WS_EX_LEFTSCROLLBAR;
return cp;
}
}
}

Also keep in mind, Setting RightToLeft property to Yes will do the trick for you, but since the RightToLeft property is an ambient property, then all children of the panel will also inherit that value and will be right to left. What I have shared here in this answer is just showing scrollbar at left side without affecting RightToLeft.

Control position changes when vertical scroll bar is displayed

You can do it this way

var count = panel2.Controls.Count;
MsgItem item = new MsgItem("testing");
item.Top = count == 0 ? 10 : (panel2.Controls[count - 1].Bottom + 10);
panel2.Controls.Add(item);

For your original code, which is

int an = 10;
private void Incoming_Click(object sender, EventArgs e)
{
MsgItem item = new MsgItem("testing");
item.Top = an;
an = item.Top + item.Height + 10;
panel2.Controls.Add(item);
}

the solution would be to track scrolling of your panel

private void panel2_Scroll(object sender, ScrollEventArgs e)
{
switch (e.ScrollOrientation)
{
case ScrollOrientation.VerticalScroll:
var change = e.NewValue - e.OldValue;
an -= change;
break;
}
}

So, for layout scenarios using TableLayoutPanel or FlowLayoutPanel is recommended

Having vertical scroll bar at the left side of the form in access 2010

Open the subform in Form design. In the Format properties of the form, change Orientation to Right-to-Left. Save the change. Now it will appear with scrollbars on the left and record selectors on the right. This will also reverse the order of columns, for forms in datasheet view.

How to change scroll bar position with CSS?

Using CSS only:

Right/Left Flippiing: Working Fiddle

.Container
{
height: 200px;
overflow-x: auto;
}
.Content
{
height: 300px;
}

.Flipped
{
direction: rtl;
}
.Content
{
direction: ltr;
}

Top/Bottom Flipping: Working Fiddle

.Container
{
width: 200px;
overflow-y: auto;
}
.Content
{
width: 300px;
}

.Flipped, .Flipped .Content
{
transform:rotateX(180deg);
-ms-transform:rotateX(180deg); /* IE 9 */
-webkit-transform:rotateX(180deg); /* Safari and Chrome */
}


Related Topics



Leave a reply



Submit