Hi hi hi,
I need to link the vertical scroll operations for two rich text boxes (already extended to a custom control so I have access to the protected members).
I found this method in a post from March '03 but I can't seem to port the code from a DataGrid to my Rich Text Boxes.
tbAy always has exactly the same number of lines as tbBee - the data displayed is related.
Yet another unchecked rambling brought to you by:
Oddball
I need to link the vertical scroll operations for two rich text boxes (already extended to a custom control so I have access to the protected members).
I found this method in a post from March '03 but I can't seem to port the code from a DataGrid to my Rich Text Boxes.
I need the first box (tbAy) to scroll to the same location as the second (tbBee).crystalruchs said:You are right that value property makes the scroll bar to change its position, but the problem is it doesn't scroll the grid also.
Following solution works for me
Create a derieved class, since HorizScrollBar property and GridHScrolled
method are protected.
Set both the datagrids to be of type MyGrid. In the scroll event justCode:public class MyGrid:System.Windows.Forms.DataGrid { public int getHorizScrollBarX() { return this.HorizScrollBar.Value; } public void setHorizScrollBarX(int x) { //this.HorizScrollBar.Value = x; this.GridHScrolled(this, new ScrollEventArgs(System.Windows.Forms.ScrollEventType.LargeIncrement, x)); } }
write.
Code:private void dataGrid1_Scroll(object sender, System.EventArgs e) { int x = dataGrid1.getHorizScrollBarX(); dataGrid2.setHorizScrollBarX(x); }
tbAy always has exactly the same number of lines as tbBee - the data displayed is related.
Yet another unchecked rambling brought to you by:
Oddball