0
Answer

move a icon(bitmap) in a certain range

LEUNG TING YU

LEUNG TING YU

14y
1.4k
1

I have a icon picsmall . It should move in y axis in a certain range . I wrote a code but when it move upwards  in a predefine value  it never move again when I move the icon downwards , what should I do ?? here is the code :
private void picSmall_MouseDown(object sender, MouseEventArgs e)
        {
            drag = true;    
            y_down = e.Y;
            picsmall.Image = imageList1.Images[0];
        }

        private void picSmall_MouseMove(object sender, MouseEventArgs e)
        {
            int co;
            if (drag)
            {
             
                if (picsmall.Top> 30)  //30 is the max value
                {
                    co = picsmall.Top;                  
                 picsmall.Top += (e.Y - y_down);          
                }
                else if (picsmall.Top == 30)
                {
                   co = 30;
                    co += (e.Y - y_down);
                              }   
        }
       private void picSmall_MouseUp(object sender, MouseEventArgs e)
        {
            drag = false;
        }