Total members 11895 |It is currently Sat Dec 21, 2024 5:35 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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.



_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

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 :(



Author:
Newbie
User avatar Posts: 27
Have thanks: 1 time

plz find the following link , it may help u

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


bona.



Author:
Post new topic Reply to topic  [ 3 posts ] 

  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     -  
 Strong tag with button tag     -  
 Nav button size     -  
 gel button in flash     -  
 disable button     -  



Topic Tags

C# Forms
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com