How to scroll two components with one's vertical scroll bar only - c#

I'm working on displaying lines numbers for a richTextBox on C#, I tried many components but non of them worked with me, so I'm working on my own one.
I implemented that using the richTextBox + ListBox.
But, I'm having a problem when scrolling the richtextbox,the ListBox wont scroll, also I need not the vScrollBar of the List box to appear during scroll how can I accomplish this?
I mean scrolling both (richTextBox+listBox) when scrolling the richTextBox only, any suggestions?

You can't make this reliable. RichTextBox allows continuous scrolling where only a portion of a line is in view. ListBox does not. The line numbers will not line up with the lines most of the time.
Use a real text editor, like ScintillaNET. It supports showing line numbers.

Add a listener on an OnScroll* event and update the other control as one of them is scrolled.

Related

A visuality gap between text box and it scroll bar

I'm creating my first windows forms app.
I've added a text box to the form and forced it to have a vertical scroll bar,
but it looks like there is a space between the text box and the scroll bar,
which of course does not look good:
AS you can see here
Appearance of the form
I've searched online and tried to "play" with the margins around the text box but i couldn't solve it
thank you.
I would try to resize the textbox (not in height but in length/width just to check if it changes anything). I had the same Issue once and could fix it with that.
~Fab

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.

c# winforms how to disable the scrollbar of richtextbox

i have a customized scrollbar, however i have tried my best to make the original one from windows invisible by using the customized one covering on it, it can not be done.
any one have idea of how remove the original scrollbar ?
this.richTextBox1.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;

create moving text

how can i make a text moving from top to bottom to top.... (like a news window) in a textBox
(Assuming windows forms)
I haven't tried to do this before, but my first attempt would include loading a bunch of text (like new headlines) into a textbox, and then making a timer that changes the vertical scroll value on the tick event? A textbox has built-in functions called ScrollToLine(), ScrollToVerticalOffset(), etc. Otherwise some controls, like panels have more direct access to scrollbar values. For example: SplitContainer.Panel1.VerticalScroll.Value = value;
If those don't work, you can always draw the text yourself via graphics object and then update the positions items are drawn at.
you can use javascript to do it for web and if it is windows have a look at this question . Hope it helps

Categories

Resources