Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Form Manipulation

Posted on 2006-10-29
9
Medium Priority
?
224 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 30

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 1000 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 30

Accepted Solution

by:
anarki_jimbel earned 1000 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 30

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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Loops Section Overview

824 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