Change PictureBox Cursor : PictureBox « GUI Windows Forms « C# / CSharp Tutorial






Change PictureBox Cursor
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

public class PictureBoxCursorChange : System.Windows.Forms.Form
{
  private System.ComponentModel.Container components = null;

  private PictureBox picBox = new PictureBox();

  public PictureBoxCursorChange()
  {
    InitializeComponent();

    picBox.SizeMode = PictureBoxSizeMode.StretchImage;
    picBox.Location = new System.Drawing.Point(64, 32);
    picBox.Size = new System.Drawing.Size(50, 50);
    picBox.Image = new Bitmap("yourFile.bmp");
        picBox.Cursor = Cursors.Hand;

    Controls.Add(picBox);
  }

  protected override void Dispose( bool disposing )
  {
    picBox.Dispose();
    if( disposing )
    {
      if (components != null) 
      {
        components.Dispose();
      }
    }
    base.Dispose( disposing );
  }


  private void InitializeComponent()
  {
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.ClientSize = new System.Drawing.Size(292, 273);
  }

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








23.22.PictureBox
23.22.1.Normal PictureBoxNormal PictureBox
23.22.2.AutoSize PictureBoxAutoSize PictureBox
23.22.3.CenterImage PictureBoxCenterImage PictureBox
23.22.4.StretchImage PictureBoxStretchImage PictureBox
23.22.5.Create an in-memory bitmap and draw and Display the bitmap in the picture boxCreate an in-memory bitmap and draw and Display the bitmap in the picture box
23.22.6.Drag and Drop ImageDrag and Drop Image
23.22.7.Add Image to PictureBoxAdd Image to PictureBox
23.22.8.Change PictureBox CursorChange PictureBox Cursor