Прокрутите 2 панели одновременно
У меня есть форматы окон (.net 2.0), в которых содержится встроенный сокет. Splitcontainer, как обычно, содержит 2 панели (стандартная вещь). Для параметра Autoscroll установлено значение true.
Я долгое время пытался добиться чего-то вроде синхронизации этих двух панелей, поэтому прокрутка одной из них будет прокручивать и вторую. Я достиг этого — используя событие Scroll (не проблема).
Однако это событие не вызывается, когда мы собираем элементы управления на одной из панелей (например, текстовые поля) — не совсем так, как на msdn.microsoft.com/en-us/library/system.windows.forms.scrollablecontrol.scroll.aspx( «Событие» Прокрутка «происходит, когда пользователь прокручивает клиентскую область, взаимодействуя со строками прокрутки или когда пользователь перемещается между элементами управления и активными свитками управления в представлении».
Итак, на самом деле панели на самом деле не синхронизированы: |
Мне известно о том, что включение фокуса в невидимый элемент управления, содержащийся в прокручиваемом элементе управления, вызывает его событие ScrollToControl (Control), которое «делает» новый элемент управления (текстовое поле) видимым. Чтобы дать более подробную информацию, я могу сказать, что обе панели идентичны (размер и элементы управления).
Синхронизация вертикальной прокрутки RichTextBox с прокруткой панели SplitContainer
Я хочу синхронизировать прокрутку RichTextBox и Panel2 наоборот. Как я могу это сделать? любая идея?
Я пытался это и он работает на двоих RichTextBox es, но не в моем случае.
задан 03 фев ’11, 23:02
1 ответы
Получите информацию о прокрутке для обоих элементов управления:
Сначала вам понадобятся следующие API Win32 (Импортирует System.Runtime.InteropServices) в ваш проект
ваш следующий шаг — следить за тем, какая полоса прокрутки изменяется . с помощью таймера и т.д . затем обновляйте другой элемент управления при необходимости.
ответ дан 10 апр.
SB_THUMBTRACK , WM_HSCROLL и WM_VSCROLL не заявлены — Tun
Не тот ответ, который вы ищете? Просмотрите другие вопросы с метками .net scroll richtextbox synchronized splitcontainer or задайте свой вопрос.
Vb net как синхронизировать прокрутку панелей splitcontainer



SplitContainer


Синхронизация вертикальной прокрутки RichTextBox с прокруткой панели SplitContainer

.NET SplitContainer with Multiple Panels
By default SplitContainer control for .NET consists of two panels which are shown one above or on left side and the other below or on right side, depending on splitter orientation. Each panel is represented by a tab title and its content panel. Although this is enough to split the content in different views in our applications, in some cases we may need to have multiple panels. A solution which will present in this article is to add multiple panels in SplitContainer, each with a different tab so that we may switch on it when necessary.

![]()
In order to create a multi-panel SplitContainer, at first we need to drag-drop the SplitContainer icon from Visual Studio Toolbox into an empty Form. This will create a new Split Container control. Than we can choose how we want to split our panels, we can do it either horizontally or vertically. By default, only two panels will be created, one above and other below the split bar, if horizontal orientation is chosen.
Now we have a SplitContainer with two panels and a split bar which consists command buttons used to expand/collapse the active view or change the splitter orientation.
In order to add more tabs to our container, we can do it from designer or through code. In our case we will do it programmatically from code. For this purpose we will create an ‘AddTab’ button which when clicked will create a new panel and add it to the container either above or below split bar, depending on ‘Tab Placement’ value.
private void btnAdd_Click( object sender, EventArgs e)
LidorSystems.IntegralUI.Containers. SplitContainerPage page = new LidorSystems.IntegralUI.Containers. SplitContainerPage ( «Panel» + ( this .splitContainer1.Pages.Count + 1).ToString());
// Depending on tab placement, add the new panel either above or below split bar
page.DisplayPosition = LidorSystems.IntegralUI.Containers. SplitPageDisplayPosition .TopLeft;
page.DisplayPosition = LidorSystems.IntegralUI.Containers. SplitPageDisplayPosition .BottomRight;
// As for content in each panel create a new Label
Label lbl = new Label();
lbl.Text = page.Text + » Content» ;
// Add the panel to the SplitContainer
// Set the new panel as currently active view
this .splitContainer1.SelectedPage = page;
Private Sub btnAdd_Click( ByVal sender As Object , ByVal e As EventArgs) Handles btnAdd.Click
Dim page As New LidorSystems.IntegralUI.Containers.SplitContainerPage( «Panel» & ( Me .splitContainer1.Pages.Count + 1).ToString())
‘ Depending on tab placement, add the new panel either above or below split bar
Issue with Syncing Scrolling Positions of two Panel Controls
I have put in my Windows Form two Panels, each is 500 px in width; Panel(1) has a height of 40 px, while Panel(2) has a height of 500 px.
Panel(1) is in top of Panel(2)
Programically, textbox controls vertically are added to Panel(2) at run time, so all those textbox controls will be displayed in one line, having each textbox.text property to have the value of a date.
The first textbox will have — for example — date = "01/01/2016"
The second textbox will have — for example — date = "01/02/2016"
The third textbox will have — for example — date = "01/03/2016"
All those text boxes have size of 40×40 px and are read-only and disabled
and so on until the last textbox will have — for example — date = "12/31/2020"
An Auto-Scroll horizontal property will be enabled for Panel(1) which will allow the user to scroll from "01/01/2016" textbox to "01/03/2016" textbox and vice versa
For Panel(2) — which also have horizontal Auto-Scroll property enabled — will have my tasks
Each task will be a textbox control added to Panel(2)
Each of those tasks will be occupying its own line. In other words; you will not see Task(1) and Task(2) in the same line, but rather Task(1) will be on top of Task(2)
Each of those tasks textboxes will have a width as per how long it will take to be completed. For example; let's say that Task(1) will take 25 days to complete, and it shall start from "01/04/2016", so this task textbox width will span in Panel(2) from the (X-position) of a textbox="01/04/2016" in Panel(1) to the (X-position + width) of textbox="01/28/2016"
All those task textboxes are also read-only and disabled
As you can see, I'm trying to draw my own Gantt Chart using Textbox controls programically at run time.
Now:
When I drag the scroller of Panel(2), I want the position of the Panel(1) to scroll as well exactly to the the same point on which I scrolled in Panel(2). I used the "Panel2.Scroll" event to do so as follows:
This is not the issue here because I successfully did it. The issue is that whenever I scroll fast from right to left or vice versa the Event handles messes up where it needs to scroll to in Panel(1). However; when I do the scrolling slow enough, then it scrolls correctly to the same point in Panel(1) as that of Panel(2)