Accessing embedded text box scroll bars
-
Anyone know how to access the scroll bars in a .NET TextBox control? I'm trapping the VScroll event which works fine except for when the user drags the scroll thumb, which for some reason doesn't fire the event. The only way I can think of is to trap the event at the ScrollBar level, but there doesn't appear to be a way to get hold of them programmatically. TIA Ian.
-
Anyone know how to access the scroll bars in a .NET TextBox control? I'm trapping the VScroll event which works fine except for when the user drags the scroll thumb, which for some reason doesn't fire the event. The only way I can think of is to trap the event at the ScrollBar level, but there doesn't appear to be a way to get hold of them programmatically. TIA Ian.
Do you mean that you want to handle event fired when the user drag the scroll thumb? MCAD
-
Do you mean that you want to handle event fired when the user drag the scroll thumb? MCAD
Thanks for your reply - yes, that's what I wanted to do. I think I've found the solution (although you may know a better way), by overriding WndProc in the TextBox as demonstrated in Help: protected override void WndProc(ref Message m) { base.WndProc(ref m); // Do first to fire the event after the text has scrolled // Listen for operating system messages. switch (m.Msg) { case WM_VSCROLL: short shtNotif = (short)((int)m.WParam & 0xffff); if (shtNotif == SB_THUMBPOSITION || shtNotif == SB_THUMBTRACK) { this.OnVScroll(new System.EventArgs()); } break; } } Ian.
-
Thanks for your reply - yes, that's what I wanted to do. I think I've found the solution (although you may know a better way), by overriding WndProc in the TextBox as demonstrated in Help: protected override void WndProc(ref Message m) { base.WndProc(ref m); // Do first to fire the event after the text has scrolled // Listen for operating system messages. switch (m.Msg) { case WM_VSCROLL: short shtNotif = (short)((int)m.WParam & 0xffff); if (shtNotif == SB_THUMBPOSITION || shtNotif == SB_THUMBTRACK) { this.OnVScroll(new System.EventArgs()); } break; } } Ian.
good you found the solution this was what i will suggest if you didn't found the solution to override
WndProc
and catch WM_VSCROLL
so this only solution i know MCAD