How to code a Scrollable Panel Control ???

  • Thread starter Thread starter Jason Jacob
  • Start date Start date
J

Jason Jacob

To all

I've posted a similar post earlier.
From the last post, I knew that .NETCF doesn't support scrollable
panes to Panel and many other controls (except TextBox, ComboBox)
To make the Panel "Scrollable", you'll need to customize it with a
VScroll Control (ie. you need to write code to simulate changes in
the VScroll control and then move the contents of the Panel Control up
or down.... quite complicated, but workable)

The problem is that I need lots of such "Controls" in my App, so is it
more practical to code that "Control" into some User-Controls (eg. OCX
objects, so that it's reusable)

If so, any help or guide on this topic ?? The contents of the
"Control" should be dynamic (at least I should have the rights to
alter its contents.... a complicated matter...)

Thanks!

From Jason (Kusanagihk)
 
Hi Jason,

What I did a time ago was include a panel inside a panel, the inner panel is
where the controls are located, the inner panel is also the one I "Scroll"
and the exterior panel's only purpouse is to hide the part of the inner
panel when I change its Top value.

Very easy indeed.

If you need this struct in several places you can create a control with such
a structure.


Cheers,
 
Yep, I'm doing the same things as you did (an outer Panel hiding an
inner Panel, scrolling then applies only to the inner panel)

But there are 2 problems:
1) I can't figure out a good and accurate formula to calculate the
distance for the inner panel to move during a vScrollBar_Change Event
(cases show that I can scroll the inner panel completely out of vision
after dragging the scroll position to the middle... ie. it scrolls too
much !)
Any ideas to simulate a better calculation??

2) since the contents of the inner panel is dynamic, I need to set out
some methods for creating the contents of the control, I find that I
can't set the contents (though compilation and Just in time debugging
passes, actually the control itself still won't be updated, and errors
occur when further action is carried out such as scrolling of the
control...)
The problem seems that -- you can't change contents in a control at
runtime, since you'll need to compile it before new changes can be
updated.

So it seems that coding the things into a generic control won't
work... But anyway Problem 1) is more essential to my situation,
Problem 2) is not a real "Problem", since you can duplicate code in
different places and that's it :)

Thanks

From Jason (Kusanagihk)
 
Hi,

I think the goal is to make the scrollbar only scroll for the difference in
height between the inner and outer panel.
This should work for you.

vScrollBar.Maximum = panelInner.Height - pnlOuter.Height;

I didn't test it so let us know if it works. Also, let us know what happens
if the inner panel is less than the hieght of the outer resulting in the
Maximum being set to a negative value.

Hope this helps,
Tom

--
Tom Krueger
Microsoft Corporation
Program Manager
http://weblogs.asp.net/tom_krueger

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 
Back
Top