c# - Class With PictureBox Variable and Double. And more -


okay, want make list or array of class has picturebox , double value varaibles. want know is, how can display class on windows form, picture, , when click on picture, message box pop , value of picture. list or array must dynamic since size of changing through out run time. hope explains need.

what have far i'm able create dynamic array of picturebox show on form, i'm not able assign double value. when click on image, can make move don't know how assign each image specific value. code stuff image on click:

private void picturebox_clickfunction(object sender, eventargs e)     {         picturebox pb2 = (picturebox)sender; // need cast(convert) sende picturebox object can access picturebox properties         if (pb2.location.y >= 250)         {             pb2.top -= 20;            // messagebox.show(pb2.tag);         }         else         {             pb2.top += 20;         }     } 

my code assigning picturebox images:

void print_deck(list<container> b, double []a)     {         double n;         y = 250; x = 66;         (int = 0; < 13; i++)         {              pb2[i] = new picturebox();             pb2[i].click += new system.eventhandler(this.picturebox_clickfunction);             pb2[i].visible = true;             pb2[i].location = new point(0, 0);             this.size = new size(800, 600);             pb2[i].size = new size(46, 65);             pb2[i].sizemode = pictureboxsizemode.stretchimage;             pb2[i].location = new point(x, y);             n = a[i];             im = face(n);             pb2[i].image = im;             this.controls.add(pb2[i]);             x = x + 20;             container newcontainer = new container();             newcontainer.picture = pb2[i];             newcontainer.number = n;             addtolist(b, newcontainer);         }     } 

and attempt @ creating class:

public class container     {         public picturebox picture { get; set; }         public double number { get; set; }     }  public void addtolist(list<container> o, container containertoadd)     {         o.add(containertoadd);     } 

most of code got asking question earlier on parts of this

you have "tag" property why not use 1 ? otherwise can extend picture box this.

  public class pictureboxext : picturebox     {         [browsable(true)]         public double somevalue { get; set; }     } 

now use pictureboxext instead of picturebox set value of picture box property "somevalue" this.

pictureboxext.somevalue  = 0.123d; 

later on pictureboxext click event be

 private void pictureboxext1_click(object sender, eventargs e)         {             pictureboxext pic = sender pictureboxext;             if (pic != null) {                 messagebox.show("double value" +  pic.somevalue);             }          } 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -