In my project i have the tabControl shown below and inside of it i have a richTextBox on which i enabled the Vertical ScrollBar...
In the richTextBox i have some "Assembly commands" and each time i highlight the instruction that is executed. My problem is when some of the last instructions i have in the textbox, must execute, those are not visible, so i have to drag manually the scrollbar.
What i'm trying to do is to set the scrollbar to move up/down by itself without any user interaction.
is there any possible solution for my problem? thanks
Related
I have a control (a text editor control) that uses the default scrollbar to scroll the text. However, clicking the scrollbar only makes it scroll a few lines.
I want to handle the scrollbar left click on my own, and make it scroll page down / page up, depending on the click, if it's above the scrollbar thumb, then page up, if it's below the thumb, page down.
TL;DR I want to know how to handle a left click on a default scrollbar and whether the cursor is above/below the scrollbar thumb. I know there's the Scroll event but it occurs after the user has scrolled, I want something like Scrolling.
If by "default scrollbar" you mean the scrollbars that are part of any ScrollableControl (UserControl, etc.), there's no need to handle the click event. The VScrollProperties class already gives you control over this out of the box:
Use ScrollableControl.VerticalScroll.SmallChange to set the distance the scroll should move when the user clicks on the scrollbar buttons (arrows).
Use ScrollableControl.VerticalScroll.LargeChange to set the distance the scroll should move when the user clicks on an empty space on the scrollbar.
Demo:
This question already has answers here:
How to capture mouse wheel on panel?
(5 answers)
Closed 4 years ago.
I've built a Windows Form, in Visual Studios 2013 using C#, that has one actual Form.cs. I have a single panel in the Form.cs that I am docking/filling with UserControl.cs files as needed. The UserControls are what I am using as the actual "user input forms" for the users to fill out controls/fields and submit the needed data. I have everything working fully/correctly except for scrolling with the mouse wheel.
Here is a typical scenario that I am trying to find a solution for; When the user first navigates to one of the UserControls, they can click on a blank portion of the window and it will allow scrolling with either the vertical scroll bar on the right or with the mouse wheel. However, when the user clicks into any control within the UserControl, a textbox, a listbox, a combobox, etc., the mouse scroll will no longer scroll the window. I have not been able to find how to allow mouse wheel scrolling by moving the focus off of the control/field and onto the UserControls background or other location to aloow the users mouse wheel to scroll the window.
One thing I must make clear is the UserControls do have the vertical scroll bar available so the user can click on the scroll bar to move the window up/down, so this portion is not an issue. I have just not been able to find a way to allow the user to scroll using the mouse wheel after they click on any control/field in the UserControl "form".
How can I move the focus off of any control/field and onto the UserControls background or other location to allow the mouse wheel to scroll the window/form/UserControl?
Edit: I have AutoScroll set to False on the Form.cs and the docked panel, however, I have AutoScroll set to True on each of the UserControls. This allows the right-hand scrollbar to render and be used however this does not seem to have any affect on the mouse-scrolling. I've tried every combination of setting the AutoScroll without success.
Edit(2):
*
* Form
- panel1
^ UserControl1.cs
^ UserControl2.cs
^ UserControl3.cs
^ UserControl4.cs
^ UserControl5.cs
Each UserControl gets applied to/rendered on panel1, based on user options. Each UserControl has the vertical scrollbar rendering on the right-hand side. Mouse-scrolling is not functioning after user clicks on/selects any control (textbox, listbox, combobox) to enter/select data. Whatever control is clicked and has focus, the focus is not moving to allow the mouse wheel to scroll the window.
This is not the most ideal answer I think but you could add Form.Focus(); to the Scroll event of every Control in your Form.
I have a Form with height size bigger then screen, so the user can use the scrollbar to see the content. My problem is, I have alot of buttons and checkboxes, all the way up and down the form, and every time the user try to click some, the form automatic try to center the clicked button in the middle of screen.
I want the scrollbar to stay where the user put it. And not trying to automatic center at every btn or iten clicked.
Can someone help with this? Its winforms, visual studio 15.
I cannot reproduce your problem but have you tried overriding the ScrollToControl?
Stop form from scrolling when moving controls
I'm having an issue where my scrollbar for a panel on a usercontrol always appears at the bottom.
If I hover the mouse over the tab and cause the control to slide out and be shown, the scrollbar is at the bottom. If I then move the scrollbar to the top and move the mouse off the control (which causes it to hide again) and then move the mouse back over the tab (which causes the control to slide back out) the scroll bar is back at the bottom!
Setting the VerticalScroll.Value property on my panel to 0 is not having any effect - the control still shows at the bottom. Can someone tell me what events might fire when a control slides back into view on an autohide tab or just tell what I could do to solve this issue! I assume that the Paint event is what fires when the control is shown but I'm not entirely sure.
I did notice that in the VS designer that the scrollbar by default is shown at the bottom. Not sure whether this may have anything to do with the issue?
Any suggestions appreciated!
Try this:
scrollingCtrl.VerticalScroll.Value = 0;
scrollingCtrl.PerformLayout();
I'm very new to WPF. I was trying to add a button to a tab item (of a tab control I had already dragged in) in Visual C# 2010 Express. Upon doing this, the button repeatedly snapped to the center of the screen when I tried to drag-and-drop reposition it. Why is this happening, and how can I move the button? I haven't written any code, and the only properties of the button that I've changed are the size, content, and name.
I had the same/similar problem today. In my case the designer had created a <border></border> around my button, with size equal to the whole application window. So, when I was moving my button around I was actually moving the border and the button and the border was snapping to the application and the button - to the border. When I removed the border - all was fixed.
Diagram explanation
See if you have such a border or other encapsulating element which may cause this behaviour.