How to prevent ScrollBar from scrolling up in FlowLayoutPanel - c#

I've been messing around with making a messager using C# and PHP. Now I'm using a flow layout panel to show my messages using a custom user control.
When I update the messages I simply clear the controls and put them in again. Just simple.
The problem is that everytime the controls are getting cleared my scrollbar goes up. I don't want that. I want the scrollbar to stay at where it is. I know It's not possible with just using the scrollbar but how could I update my controls without clearing the list?

Related

WPF Force UI to update

In my application user can scroll up/down MainWindow.
Problem is, that when a user scrolls down MainWindow and some controls in it are not entirely visible ( for example user scrolled down and only the bottom of the control is visible) these controls are not refreshing/updating its values (provided via binding). I suspect that WPF is detecting, that control is not visible in some way and does not bother to update UI of it. So how can I force these controls to update their UI?
For example, in picture below there is some chart in the MainWindow.But the window is small and scrolled down so the chart is not entirely visible. It does not update, it is still. When I maximize the window chart starts updating. I want it to update always, no matter how small part of it is visible:
This is a virtualization problem, and you need to turn off virtualization for your chart (look at the chart vendor's documentation).
In the standard WPF controls there are many ways to do this.

How to stop VScrollbar from flashing when selected

I have a System.Windows.Forms.VScrollBar control on my form and select it programmatically by calling scrollBar.Select() so that mouse-wheel and keyboard scrolling just works (without the user having to explicitly select the scrollbar beforehand). However, this causes the scrollbar cursor to constantly flash every half a second or so. Is there any way to stop this behaviour? I have looked around but I can't find any property to control this behaviour?
I even tried creating a custom scrollbar inherting from VScrollBar and overriding OnPaint, but that's not even getting called, so I guess its not used by VScrollBar at all.
I don't know that keyboard scrolling can be easily implemented on a WinForms AutoScroll control (see this answer). I do know that so long as the AutoScroll control has focus in the form, mouse-wheel scrolling should work without the user selecting the scrollbar itself. I suggest that rather than calling scrollBar.Select() to accomplish what you need, you instead call scrollBarParent.Focus(). This should take care of the flashing issue.

Virtualize GridView inside ScrollViewer in Windows Store App

I have the following application:
I am developing a Windows Store app in which I need to show a big grid filled with buttons. The content of the buttons are some numbers and when I click any of them, I open a Popup with editor, where I edit those numbers. For that purpose I use a GridView, I put an ItemsWrapGrid as ItemsPanel. This makes the grid look exactly as I need it to look. I put the GridView inside a ScrollViewer, because I need to scroll the grid in both directions, since it has a lot of elements. Also I need to have the pinch-to-zoom effect that the ScrollViewer gives out of the box. I need to change the ItemsSource for that GridView when the user chooses different source in a ListView next to the GridView.
The problem:
Putting the GridView inside the ScrollViewer breaks the Virtualization inside and this has a major impact on my performance. When I switch the ItemsSource of the GridView, it takes more than 3-4 seconds for the rendering and during that time, the UI is frozen.
My question:
How can I keep the awesome stuff that the ScrollViewer gives me and also keep the virtualization? Because when I remove the ScrollViewer, changing between the ItemsSources happens almost instantly.
Any idea?
You'll be best off implementing virtualization yourself since you're trying to use the GridView far from the use cases it was designed for.
Put a Canvas in a ScrollViewer that does both pan and zoom and handle view change events on the ScrollViewer by laying out item containers inside and around the viewport. Avoid unnecessary changes too, so keep containers in place if they are to stay realized between view change events and recycle containers that are leaving the viewport neighborhood.

Winforms: How to Enable Scroll Event Without Scrollbar in DataGridView

I have looked on stackoverflow and have not seen a solution (but may have missed it).
I want to scroll the datagridview contents with a swipe. A swipe gesture in Windows 8.1 seems to translate appropriately to a scroll event which causes the desired result. I can get the scroll event to show up if I have the scrollbar in the datagridview control. Consequently, to get scrolling to occur in the control with a swipe, I am looking for either (1) a way to have the scroll event occur without the scrollbar or (2) a way to hide the scrollbar. Option 1 is preferable since having the extraneous scrollbar around seems like a bit of a hack. I have a custom scrollbar outside of the datagridview which is why I want to hide the internal datagridview scrollbar.
Thanks for looking and any help you can provide.

Control over Listbox not prevent scrolling

I made a hiding bar into my application using a simple control, using a TranslateTransform.
When the bar is showed is overlapping a listbox.
What i didn't expect is that scrolling on the control don't prevent to scroll also the overlapped listbox.
I need that the listbox don't scroll when i'm working on the control.
I made a video in order to better explain the issue.
http://www.youtube.com/watch?v=9UM2lzPz8p0
[Update]
solved using UseOptimizedManipulationRouting="False"

Categories

Resources