C# Dynamically added Event Handles (?)

Discussion in '.NET' started by DarrenDS, Jul 22, 2008.

  1. DarrenDS

    DarrenDS

    Joined:
    Jul 21, 2008
    Messages:
    1
    Location:
    Geelong Australia
    Hi All.. (Be Gentle.. I'm new :oops: ) using C#.. below is my snippit of code..

    I am Dynamically (While there a more .jpg's in a dir)
    adding cells to a table with an image and a button

    Question ..
    How do I add a :
    • MouseOver/MouseOut event to the Image and a
    • Clicked event to the Button

    TableRow r = new TableRow();
    for (int i = 0; i < numCells; i++) {
    TableCell c = new TableCell();
    if(count < numFiles){

    label1.Text = "here 2";

    fileName = files[count].ToString();
    int LastIndex = fileName.LastIndexOf("\\");
    fileName = fileName.Substring(LastIndex+1,(fileName.Length - LastIndex -1));

    Image theImage = Make_Image(theDir + "/" + fileName);
    Image theOtherImage = Make_OtherImage(theDir + "/" + fileName);
    Button theButton = Make_Button(fileName);
    c.Controls.Add(new LiteralControl("<div id='pic'><a href='#'>"));
    c.Controls.Add(theImage);
    c.Controls.Add(theOtherImage);
    c.Controls.Add(new LiteralControl("</a></div>"));
    c.Controls.Add(theButton);
    }
    r.Cells.Add(c); count++;
    }
    Table1.Rows.Add(r);



    Loveuuz all....

    Darren.
     
    DarrenDS, Jul 22, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MS Newsgroups
    Replies:
    5
    Views:
    1,534
    Anders Borum
    Dec 13, 2003
  2. JoakimR
    Replies:
    3
    Views:
    3,681
    John Saunders
    Jan 8, 2005
  3. Jon B
    Replies:
    5
    Views:
    5,249
    billmiami2@netscape.net
    Apr 30, 2005
  4. Jeffrey Todd
    Replies:
    1
    Views:
    4,152
    Peter Blum
    Jun 2, 2005
  5. eino
    Replies:
    1
    Views:
    452
    =?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=
    May 8, 2007
Loading...

Share This Page