Question: Textbox or richtextbox, only thing i want is triggering a function when scrollbar moves.

I already found GetScrollPos and SetScrollPos. I thought of checking scrollbar position periodically but there must be a better way. So, what is the better way?

Update: Using WinForms

Answer: 
Assuming WinForms, you can try pinvoking:

```
public class MyRTF: RichTextBox {

  private const int WM_HSCROLL = 0x114;
  private const int WM_VSCROLL = 0x115;
  private const int WM_MOUSEWHEEL = 0x20A;

  protected override void WndProc(ref Message m) {
    base.WndProc(ref m);

    if (m.Msg == WM_VSCROLL || m.Msg == WM_HSCROLL || m.Msg == WM_MOUSEWHEEL) {
      // scrolling...
    }
  }

}

```
Even better -- the hidden `MouseWheel` event: <https://stackoverflow.com/a/26672097/1037948>

```
public Form1()
{
    InitializeComponent();
    textBox1.MouseWheel += textBox1_MouseWheel;
}

void textBox1_MouseWheel(object sender, MouseEventArgs e)
{
    throw new NotImplementedException();
}

```