logo
down
shadow

How can I add a vertical scrollbar to my div automatically?


How can I add a vertical scrollbar to my div automatically?

Content Index :

How can I add a vertical scrollbar to my div automatically?
Tag : css , By : Joshua Johnson
Date : November 25 2020, 07:22 PM


Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Automatically display vertical scrollbar in multiline text edit control


Tag : cpp , By : Terrence Poon
Date : March 29 2020, 07:55 AM
should help you out On a windows mobile device I have a mutliline text edit control that is set to read-only and has some static text displayed during it's display lifetime. I would like to only display a vertical scrollbar when it's actually useful (i.e. the text is larger than the display). , This is how I solved this problem.
First off:
 void CMessageDlg::OnTimer( UINT_PTR nIDEvent )
  {
    switch(nIDEvent)
    {
    case DO_ADJUST_DISPLAY_STATE:
        KillTimer(nIDEvent);
        // deselect all text
        m_Message.SetSel(0, 0);
        SCROLLINFO info;
        m_Message.GetScrollInfo(SB_VERT, &info);

        if(info.nPage > (UINT)info.nMax)
        {
            // need to re-display the non scroll bar version
            m_Message.ShowScrollBar(SB_VERT, FALSE);

            // I could not find any other way to force a redisplay 
            // correctly without display problems...

            // first move the window to a know invisible area
            // then wait (using a timer) for the window to move
            // then move the window back to it's original position     
            RECT rt;
            rt.left = 0;
            rt.right = 5;
            rt.top = 0;
            rt.bottom = 5;
            m_Message.MoveWindow(&rt);

            SetTimer(DO_REDISPLAY_MESSAGE, 50, 0);
        }
        break;

    case DO_REDISPLAY_MESSAGE:
        KillTimer(nIDEvent);
        // m_MessagePosition holds the original position
        // worked out dynamically during the WM_SIZE
        // processing
        m_Message.MoveWindow(&m_MessagePosition);
        break;
    }
}

Android: How to automatically display vertical scrollbar?


Tag : android , By : user183345
Date : March 29 2020, 07:55 AM
hop of those help? Remove the scrollbar attributes and wrap the whole thing in a ScrollView.

C#: will a vertical scrollbar appear on a listbox automatically?


Tag : development , By : Doc Immortal
Date : March 29 2020, 07:55 AM
To fix the issue you can do If I fill a ListBox with items, will a vertical scrollbar automatically appear when there are too many items to display, or is there something that needs to be set for this to occur? , YES, that it will.

how to automatically set the value of maximum property of vertical scrollbar depending on a panel's height


Tag : vb.net , By : user123585
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Handle the SizeChanged event of the Panel, get its Height property, process as required and assign the result to the Maximum of the VScrollBar. Similarly for the Width and Maximum of an HScrollBar.

Automatically fit Columns to Listview for Vertical Scrollbar


Tag : chash , By : user150744
Date : March 29 2020, 07:55 AM
it should still fix some issue when the (default) scrollbar appears inside the listview the size of the last column is not automatically fixed/decreased ... "default scrollbar" taken to mean the Veritical Scroll.
AutoResize is not AutoFit. It is for sizing columns based on the Header text extent or content length, not managing scrollbars and works very well. If it did automatically resize the last column, we would be angry when the last column is a small 'OK?' type column which was rendered unreadable when it was AutoFitted away.
Public Const WS_VSCROLL As Integer = &H200000
Public Const WS_HSCROLL As Integer = &H100000
Friend Enum SBOrientation As Integer
    SB_HORZ = &H0
    SB_VERT = &H1
    SB_CTL = &H2
    SB_BOTH = &H3
End Enum

<DllImport("user32.dll")> _
Private Shared Function ShowScrollBar(ByVal hWnd As IntPtr,
                     ByVal wBar As Integer,
                     <MarshalAs(UnmanagedType.Bool)> ByVal bShow As Boolean
                     ) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function

<DllImport("user32.dll", SetLastError:=True)> _
Private Shared Function GetWindowLong(ByVal hWnd As IntPtr, 
             ByVal nIndex As Integer) As Integer
End Function

Friend Shared Function IsHScrollVisible(ByVal ctl As Control) As Boolean
    Dim wndStyle As Integer = GetWindowLong(ctl.Handle, GWL_STYLE)
    Return ((wndStyle And WS_HSCROLL) <> 0)
End Function

Friend Shared Function IsVScrollVisible(ByVal ctl As Control) As Boolean
    Dim wndStyle As Integer = GetWindowLong(ctl.Handle, GWL_STYLE)
    Return ((wndStyle And WS_VSCROLL) <> 0)
End Function

Friend Shared Sub ShowHideScrollBar(ByVal ctl As Control, 
        ByVal sb As SBOrientation, ByVal bShow As Boolean)
     ShowScrollBar(ctl.Handle, sb, bShow)
End Sub
Private orgClient As Rectangle      ' original client size for comparing
Private _VScrollWidth As Integer 

Private _resizedCol As Integer = -1
Private _VScroll As Boolean = False    ' persistent Scroll flags 
Private _HScroll As Boolean = False

' 3rd party???
_VScrollWidth = System.Windows.Forms.SystemInformation.VerticalScrollBarWidth
orgClient = Me.ClientRectangle
' method on subclassed LV:   from form load: thisLV.ResetClientSize

Public Sub ResetClientSize          
   orgClient = Me.ClientRectangle   
End Sub
' a helper:
Private Function AllColumnsWidth() As Integer
    Dim w As Integer = 0
    For Each c As ColumnHeader In Columns
        w += c.Width
    Next
    Return w
End Function

' The Meat
Protected Overrides Sub OnClientSizeChanged(ByVal e As System.EventArgs)
    Dim VScrollVis As Boolean
    Dim HScrollVis As Boolean

    ' get who is Now Showing...local vars
    VScrollVis = NativeMethods.IsVScrollVisible(Me)
    HScrollVis = NativeMethods.IsHScrollVisible(Me)

     ' width change
    Dim delta As Integer = (orgClient.Width - ClientRectangle.Width)

    Dim TotalWidth As Integer = AllColumnsWidth()
    If (TotalWidth < ClientRectangle.Width - _VScrollWidth) And 
           (_resizedCol = -1) Then
        Exit Sub
    End If

    Me.SuspendLayout()

    ' If VScroll IS showing, but WASNT showing the last time thru here
    '  ... then we are here because VScroll just appeared.
    ' That being the case, trim the desired column
    If VScrollVis And _VScroll = False Then
        ' a smarter version finds the widest column and resizes THAT one
        _resizedCol = Columns.Count - 1

        ' we have to wait for the HScroll to show up
        ' to remove it
        Columns(_resizedCol).Width -= (delta + 1)

    End If

    ' HScroll just appeared
    If HScrollVis And (delta = _VScrollWidth) Then

        ' HScroll popped up, see if it is needed
        If AllColumnsWidth() <= orgClient.Width Then
            ' no, go away foul beast !
            NativeMethods.ShowHideScrollBar(Me,
                        NativeMethods.SBOrientation.SB_HORZ, False)

            _HScroll = False             ' hopefully

            ' allows us to set it back if the VScroll disappears
            orgClient = ClientRectangle
        Else
            ' ToDo: use this to detect when none of this is needed
            _HScroll = HScrollVis
        End If
    End If

    ' If VScroll ISNOT showing, but WAS showing the last time thru here
    '   ...then we are here because VScroll disappeared
    If VScrollVis = False And _VScroll = True Then
        ' put back the pixels

        If _resizedCol <> -1 Then
            Columns(_resizedCol).Width += (_VScrollWidth + 1)
            ' reset column tracker
            _resizedCol = -1
            ' reset to new compare size
            orgClient = ClientRectangle
        End If

    End If

    _VScroll = VScrollVis

    Me.ResumeLayout()

End Sub
Related Posts Related QUESTIONS :
  • How to fit innerHtml into a p tag
  • How can i make border for active class nav-item in bootstrap 4?
  • Mixing Multiple conditions in a Single NgStyle Tag?
  • I need an element to be a child of other without inheriting certains properties
  • React - JSS have element fade in when rendered
  • Chrome's hidden CSS scroll-snap threshold and how to change it
  • Why can't I see my linear gradient over my background image?
  • Trying to hide a div using CSS
  • How to import css to only one component?
  • Best practices for styling an element that can be positioned anywhere in a page
  • should i use media queries for responsive design with react?
  • Color words ending with a digit?
  • Long Text inside Table Cell Overflow
  • Center text in column/vertically, CSS Grid
  • MDC-Web CSS theme colors not defined
  • css transform + width + left + top transition jump on safari browser
  • How to correctly position vertical oriented text on a div?
  • Why does position: sticky; not work in react?
  • Is there a way to snake/queue the flow of items in a CSS Grid?
  • two screen widths: 375px and 1024px
  • React native - Highlight a TextInput if it's empty on form submit
  • How to get the css property of a tags in testcafe?
  • Cropping the top 10% of an image using CSS?
  • how to keep a footer at the bottom of the page, even if the content grows?
  • Firefox: How to test prefers-color-scheme?
  • Is there anyway to remove the shadow, or force vuetify menu to fully align with the left side of the screen?
  • How do I convert CSS to Styled-Components with input[type="submit"] attribute?
  • How to Bold first line of :before content in Firefox?
  • Changing diameter of Angular material spinner breaks it
  • Automatically suffix every style with !important
  • Define a class is not working globally but locally it is
  • css does not work on selected row of a tableview in order to change the text color
  • Is it possible to create a button using nothing but CSS that changes the appearance of a page?
  • Running footer "element(footer)" in paged media appear only in last page
  • responsive web design video container whitespace
  • Select last element without a class
  • CSS: Can I put text over an image without having the text overflow?
  • Add styling to an angular custom component
  • JavaFX have scroll-bar transparent for all elements (scoll pane, text area, etc)
  • How to add 'title' tag (for tooltip) in react styled components
  • Input:checked + after element not working
  • css multiple selector last one doesn't work
  • Css variable in Email Template
  • css pseudo class applied to "a" tag with multiple classes
  • How do I cause a pseudo element to span over blank grid cells?
  • Is it possible to replicate bootstrap 4 col class in CSS Grid?
  • Flexbox - first column full height
  • apply style to ul li after a div span that has a specific class
  • "Inheritance" of a CSS selector
  • Material Ui (reactjs) - Center a logo image in the appBar
  • Placing Link Text Within a Button in Angular App
  • How to center an image in ReactJS using css
  • Less - how to generate values in a loop
  • React/CSS: Using CSS stylesheets in a React app?
  • Why is Safari‚Äôs default font tracking/letter-spacing different than other browsers?
  • How to set text color depends on element class name in css3
  • Encapsulating CSS code in javascript plugin
  • How to give margin-left in proportion to margin-right?
  • change text align according to mobile device in Bootstrap 4
  • ng-deep is effecting sibling components
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com