-1

I am working in DevExpress Gridview Concepts. I require one User Image in my grid field. i m working in winforms platforms.

My Datatable has only path of image. I dont know how to bind an image to repositoryPictureEdit Control

Kindly provide any solution.

Jens Kloster
  • 11,099
  • 5
  • 40
  • 54
Sneha
  • 11
  • 1
  • 7

1 Answers1

0

You could using a ImageEdit. This is a dropdown of Images. So you generate Images first via:

Image.FromFile(Path);

Add them to a List or ImageList and fill the dropdown with it. Then you just bind the index of the picture to your column.

I hope this is able to work in your case.

edit: OR

At first you have to create a UnboundColumn in your Grid. Just create a column and set the Property 'UnboundType' to object. Then set a RepositoryPictureEdit as ColumnEdit. Now you have a Column which got a pictureedit in each row. To populate the Images you can handle the CustomUnboundColumnData event. This event you can find on the GridView.

To accomplish this task do following:

  • Run GridView Designer -> Change to columns at the left side
  • Add Column
  • In the Propertywindow ->

  • set the Columnedit to repositorypictureedit

  • set the UnboundType to object

  • Activate the CustomUnboundColumnData event (you can find in the GridView) -> this event fires on loading Grid for every cell.

With e.ListSourceRowIndex you can get the row of your datasource appending to the unboundcolumn. So you could do following:

   private void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
            {
                if (e.Column.Name == "MyColumn")
                {
                    clsTest test = myListAsDataSource[e.ListSourceRowIndex];
                    e.Value = test.Bild;
                }
            }

I hope this can help you.

Sebi
  • 3,879
  • 2
  • 35
  • 62
  • thanks Sebi.. I got exact ans.. I used Picturebox.image=Image.FromFile(Path) n i got Image in picturebox But how to show that image in grid cell???? Can you help with this???? thanks Again... – Sneha Apr 03 '13 at 09:27
  • thanks for reply but i did not able to call that function even using populate columns.. how can i use that function? or how that event is occured? – Sneha Apr 04 '13 at 05:16