Switch to full style
C# examples
Post a reply

put image on button in C#

Sun Jan 04, 2009 12:42 pm

This code is to put an image on your C# button,you will need to change the the image name with the one you have .

Code:

using System
;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

public class 
AppForm Form
{
    private 
System.Windows.Forms.Button mybutton;

  public 
AppForm() {
        
InitializeComponent();
  }

    private 
void InitializeComponent()
    {
        
this.mybutton = new System.Windows.Forms.Button();
        
this.SuspendLayout();

        
this.mybutton.Image = new Bitmap("Click.jpg");
        
this.mybutton.ImageAlign System.Drawing.ContentAlignment.TopRight;
        
this.mybutton.Location = new System.Drawing.Point(13100);
        
this.mybutton.Name "mybutton";
        
this.mybutton.Size = new System.Drawing.Size(14080);
        
this.mybutton.TabIndex 1;
        
this.mybutton.Text "My Button";
        
this.mybutton.TextAlign System.Drawing.ContentAlignment.MiddleLeft;
        
this.button1.UseVisualStyleBackColor true;
 
        
this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
        
this.AutoScaleMode System.Windows.Forms.AutoScaleMode.Font;
        
this.ClientSize = new System.Drawing.Size(300270);

        
this.Controls.Add(this.button1);
        
this.Font = new System.Drawing.Font("Tahoma"8.25FSystem.Drawing.FontStyle.RegularSystem.Drawing.GraphicsUnit.Point, ((byte)(0)));
        
this.Name "Image on Button";
        
this.Text "Image on Button";
        
this.ResumeLayout(false);

    }

  [
STAThread]
  static 
void Main()
  {
    
Application.EnableVisualStyles();
    
Application.Run(new AppForm());
  }

}

 


I Hope you found it useful.



Re: put image on button in C#

Wed Sep 22, 2010 1:07 pm

Hey this is so complicated....
I think there is also another way to add image on button...
I tried this but i got errors while executing :(

Re: put image on button in C#

Mon Feb 06, 2012 6:17 pm

plz find the following link , it may help u

Code:
http://csharp.net-informations.com/gui/button.htm


bona.

Post a reply
  Related Posts  to : put image on button in C#
 Convert link and button to custom button with good style     -  
 Image-Viewer-Image Processing-Filters-Noise-enhancements     -  
 Move image in front of a background image     -  
 different between cfa image and gray level image     -  
 PNG image to the image you generated     -  
 Gel Button     -  
 gel button in flash     -  
 disable button     -  
 create a web 2.0 button     -  
 Glare button     -  

Topic Tags

C# Forms