Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to display default image in datagridview in c#.net 3.5 Win Forms?

how to display default image in datagridview in c#.net 3.5 Win Forms?

Scheduled Pinned Locked Moved C#
csharpquestionhelptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Narendra Reddy Vajrala
    wrote on last edited by
    #1

    Hi Experts, am working with c#.net 3.5, Windows Application How can i add a default image to every row of my datagridview? please help me out. Thanks In Advance. :-O

    H 1 Reply Last reply
    0
    • N Narendra Reddy Vajrala

      Hi Experts, am working with c#.net 3.5, Windows Application How can i add a default image to every row of my datagridview? please help me out. Thanks In Advance. :-O

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      The easiest way to do this is to use an unbound DataGridViewImageColumn. Something like this:

      		// Create the image column.
      		DataGridViewImageColumn imageCol = new DataGridViewImageColumn();
      		imageCol.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
      		imageCol.ImageLayout = DataGridViewImageCellLayout.Normal;
      		imageCol.Frozen = true;
      		imageCol.Name = "Image";
      		imageCol.HeaderText = "";
      
      		// Move the column to the left
      		// column out of the way.
      		imageCol.DisplayIndex = 0;
      
      		// By default, show the generic image.
      		imageCol.Image = genericImage; // <==================== put your image here
      
      		// Add the image column to the grid.
      		dataGridView1.Columns.Add(imageCol);
      

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups