Solved

Form Manipulation

Posted on 2006-10-29
9
216 Views
Last Modified: 2010-04-16
Lets say you have a form that is 300 high by 700 long.... now the user fires an event and the bottom half of the form slides out slowly so not you have a form that is 700 high by 700 long.

You see the effect I am looking for, any code examples would be greatly appreciated.
0
Comment
Question by:schenkp
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 29

Expert Comment

by:anarki_jimbel
ID: 17830636
Not exactly sure what do you want to achieve. However, if for example user presses a button the form should change its height to 700. Slowly :)
That's pretty easy:

        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.Height += 10;
            if (this.Height >= 700)
                timer1.Stop();
        }

All you need is to twick a bit with timer interval and increment (this.Height += 10).
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17830655
i think the timer is overhead, why not simply put the height in the event handler and avoid the timer?

private void button1_Click(object sender, EventArgs e)
        {
            while (this.Height < 700) {
                this.Height += 50;
            }
        }
0
 

Author Comment

by:schenkp
ID: 17830686
Not the effect I’m looking for maybe i did not explain myself thoroughly enough....

I would like the hidden area to slide into the bottom of the form over say 4 seconds....
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 13

Expert Comment

by:newyuppie
ID: 17830697
if you want to do it in a predefined time you will need to use a timer as anarki_jimbel suggested...
so you need to make the form 700 height, and currently its 300 height. so you need to sum about 100 to its height every second to get to 700.

set the timer's interval to 1000 (1s) and

private void timer1_Tick(object sender, EventArgs e)
        {
            this.Height += 100;
            if (this.Height >= 700)
                timer1.Stop();
        }

as he suggested.
0
 
LVL 13

Assisted Solution

by:newyuppie
newyuppie earned 250 total points
ID: 17830706
if you would like nicer slide effect, you should do some calculations on your head. for example, drop the Interval to 500 (half a second) and increase height by 50. or drop the timer interval to 250 (quarter of a second) and increase height by 25. just simple math, as you keep getting the interval smaller, calculate how many intervals it will take to get the correct height when it hits 4 seconds.
if you keep calculating where i left off and use my system, you need to halve the interval and halve the height. this way you wont get lost.

0
 
LVL 29

Accepted Solution

by:
anarki_jimbel earned 250 total points
ID: 17830726
2 newyuppie

"i think the timer is overhead"
Don't think so: while you run 'while' loop you form is effectivly unaccessible. Bad practice.

2 schenkp
Pls explain your scenario once more.
As I understand now, avter the event 'hidden' area became visible and dissapears after say for seconds?
Or some 'hidden are' stretches to bottom after 4 seconds?
Or what?
0
 

Author Comment

by:schenkp
ID: 17830828
OK I have 2 panels visible in the 300 x 700 area, in the hidden area I have a some more panels and some controls  etc.   When an event is fired in the 300 x 700 area I would like the bottom half to slide out from 300 x 700 to 700 x 700 over a 4 second period.  
I don’t want the opacity to fade in, I would like to have the panel slide out if possible.  
I am will to buy a 3rd party piece of software to achieve this effect if I have to.
0
 
LVL 29

Expert Comment

by:anarki_jimbel
ID: 17830891
It's not too basic task, I think.
say I have two panes, one visible and one hiddent beneath. When I click the button I shift panel2 location to make it visible.
That's easy. However redrawing the form may look ugly but this is another story:

        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.Height += 10;

            panel2.SetBounds(panel2.Location.X, panel2.Location.Y+10,panel2.Height, panel2.Width);
            if (this.Height >= 700)
                timer1.Stop();
        }

0
 
LVL 12

Expert Comment

by:sandip132
ID: 17832580
use Javascript :

http://www.dhtmlcentral.com/script/script.asp?id=25

In this example you can write your html code in menu division.

0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question