none
Imagens no reportviewer com Access RRS feed

  • Pergunta

  • Boa Noite
    Tenho um simples projeto (Windows Form) utilizando o banco de dados em Access com os campos ID, Nome e Imagem (guarda apenas o caminho da imagem), gostaria de ajuda para inserir as imagens do banco no ReportViewer, pois há vários dias estou tentando alguns códigos, dicas e exemplos dado em video, mas sem sucesso. Apenas aparece um “X” vermelho no lugar das fotos. Não encontrei nada por aquí referente a isso. Estou desenvolvendo em C# no VS 2010 com ACCESS.

    Poderia me ajudar?

    Desde já agradeço a colaboração…Obrigado!

    sexta-feira, 24 de outubro de 2014 03:19

Respostas

  • Nesse tutorial tem exemplo de 2 formas: http://www.c-sharpcorner.com/uploadfile/abylex/show-images-in-reports-at-run-time-using-reportviewer/

    In ReportViewer, you have 2 options for images: External or Embedded.

    1. 
    Embedded: 

    If you have images in your application and you want to use them. 

    Stage I: Then, you first need to embed the images in to be used in Reports. To embed an image in Reports: 
    a) Open the RDLC File.
    b) Go to the Menu Item: 
    Report > Embedded Images. Click on: New Image.
    c) Browse for the image. Edit 
    Name for the image chosen as desired (example, here:TestImage). OK.

    Stage II:
    d) Use an Image control on your RDLC file.
    e) Set the 
    Image's Property-Source = Embedded.
    f) Reserve a Report's DataSource Member for the image Path. For example-DataSource.ImgPath.
    g) Set the value for image path from the code in 
    DataSource.ImgPath. 
        For example: DataSource.ImgPath = "TestImage";
    h) Do the normal stuff to bind DataSource etc.
    i) Done. Enjoy your image in the Report.



    2. 
    External: 

    If you do not have images in your Application. That is, you want to use an external image.

    a. Use an Image control on your RDLC file.
    b. Set the 
    Image's Property-Source = External.
    c. Reserve a Report's DataSource Member for the image Path. For example-DataSource.ImgPath.
    d. Set the value for image path from the code in 
    DataSource.ImgPath.
        For example: DataSource.ImgPath = "http://www.google.com/intl/en_ALL/images/logo.gif";
    e. The following self explanatory code also needs to be written:
        reportViewer1.LocalReport.EnableExternalImages = true;  (reportViewer1 is the Name for the   ReportViewer Control)
    f. Do the normal stuff to bind DataSource etc.
    g. Done. Enjoy your image in the Report.

    sexta-feira, 24 de outubro de 2014 11:10

Todas as Respostas

  • Nesse tutorial tem exemplo de 2 formas: http://www.c-sharpcorner.com/uploadfile/abylex/show-images-in-reports-at-run-time-using-reportviewer/

    In ReportViewer, you have 2 options for images: External or Embedded.

    1. 
    Embedded: 

    If you have images in your application and you want to use them. 

    Stage I: Then, you first need to embed the images in to be used in Reports. To embed an image in Reports: 
    a) Open the RDLC File.
    b) Go to the Menu Item: 
    Report > Embedded Images. Click on: New Image.
    c) Browse for the image. Edit 
    Name for the image chosen as desired (example, here:TestImage). OK.

    Stage II:
    d) Use an Image control on your RDLC file.
    e) Set the 
    Image's Property-Source = Embedded.
    f) Reserve a Report's DataSource Member for the image Path. For example-DataSource.ImgPath.
    g) Set the value for image path from the code in 
    DataSource.ImgPath. 
        For example: DataSource.ImgPath = "TestImage";
    h) Do the normal stuff to bind DataSource etc.
    i) Done. Enjoy your image in the Report.



    2. 
    External: 

    If you do not have images in your Application. That is, you want to use an external image.

    a. Use an Image control on your RDLC file.
    b. Set the 
    Image's Property-Source = External.
    c. Reserve a Report's DataSource Member for the image Path. For example-DataSource.ImgPath.
    d. Set the value for image path from the code in 
    DataSource.ImgPath.
        For example: DataSource.ImgPath = "http://www.google.com/intl/en_ALL/images/logo.gif";
    e. The following self explanatory code also needs to be written:
        reportViewer1.LocalReport.EnableExternalImages = true;  (reportViewer1 is the Name for the   ReportViewer Control)
    f. Do the normal stuff to bind DataSource etc.
    g. Done. Enjoy your image in the Report.

    sexta-feira, 24 de outubro de 2014 11:10
  • No meu caso eu usaria o modo External, pois o caminho da imagem está no banco de dados (Access), mas como farei para passar o caminho da imagem que já está na tabela inserido no campo IMAGEM conforme o passo d. ?  Desculpa pela dificuldade que estou tendo com esse assunto.

    Peço a gentileza de ver o video no link abaixo, eu segui exatamente conforme o video, talvez entenda melhor o que está faltando ou o que eu deveria ter feito mas não está explicando no video:

    http://www.youtube.com/watch?v=kQN0iaEw9cs

    PS. só lembrando que estou programando em c# no VS 2010.

    Agradeço!

    sábado, 25 de outubro de 2014 20:10