Assigning an image to a button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • programmerboy
    New Member
    • Jul 2007
    • 84

    Assigning an image to a button

    Hi,
    I am using and trying to create a button through code. I want to assign an image to the button, but I think something is wrong in my code. Can anyone please let me know how to assign an image to a button through code.
    Thanks

    Code:
    ctrlButton = New Button
    CType(ctrlButton, Button).Image = New System.Drawing.Image(strConfigFilePath & "Folder.ico")
  • YGayatri
    New Member
    • Nov 2007
    • 9

    #2
    Can try as below:

    CODE]ctrlbutton = new Button();
    this.Controls.A dd(ctrlbutton);
    //ctrlbutton.Text = "MY Button";
    ctrlbutton.Imag e = new System.Drawing. Bitmap("<<path> >");
    [/CODE]

    Comment

    • programmerboy
      New Member
      • Jul 2007
      • 84

      #3
      Originally posted by YGayatri
      Can try as below:

      CODE]ctrlbutton = new Button();
      this.Controls.A dd(ctrlbutton);
      //ctrlbutton.Text = "MY Button";
      ctrlbutton.Imag e = new System.Drawing. Bitmap("<<path> >");
      [/CODE]
      Thanks!! Actually I was able to figure it out after I posted. But anyways, thanks again.

      Comment

      Working...