Hello,
I have a UserControl (UC) on a TabPage. The UC contains many standard controls (a TreeView, some TextBox controls, labels, etc.). In its minimum state the UC is too large for the tab, so I turned on autoscroll for the tab.
Here's the problem: the first time the user clicks a node in the TreeView within the UC, the TreeView control that just gained focus is scrolled to the top of the tab. I want to block this scrolling event. There are some critical buttons at the top of the UC that go out of view when the scrolling event occurs. They should remain visible as they are the next step in the workflow. Since I can't move the buttons (this UC is being reused in this tab), I want to block the scroll.
The main problem for me is that I don't know the chain of events that cause the scrolling event to fire. I know that the focus event initiates the chain of events, but I don't know exactly which events follow.
Any help would be greatly appreciated.
Thank you,
Robert
Robert RybczynskiPosted Feb 7, 2008, 9:35 AM
Thanks, but I really can't reorganize the UC due to reuse. By dismantling the contol to cure this problem, I'd be creating problems elsewhere. The software has already been through three rounds of testing and this is really the only significant bug left before beta. Therefore, I am reluctant to change structure. There is a simple workaround until the next release. Since I still have a few days, though, I'd like to nail this one down.
One thing I'm considering is to post my own event when the node is selected in the TreeView. Interested objects (in this case, my tab) could then react. I might just position the tab's autoscroll to the top position, thus exposing the toolbar of the UC. It's ugly, but it will get the job done.
I have a subscription to MSDN and I've read several pages on event handling. Unfortunately, nothing yet that covers precisely this problem. Can anyone post a link that speaks to autoscrolling events? I'm sure it's in there somewhere and I just can't find it.
Scott LyslePosted Feb 7, 2008, 12:59 AM
You could use a split panel container in the control. If you drop one on the form and set the orientation to horizontal, you could load your top controls into that panel. You could then drop a second split panel container in the bottom panel of the first split panel container and then put your treeview on the left side and your other content on the right side.
If need be, you can set any of the panels to be fixed.