Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old August 19th, 2004, 01:27 AM
Authorized User
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default bindings & images


How must I do to bind a picture with a picture box?

When I tried it, I get an invalid typecast exception.

Binding ImageBinding;
ImageBinding = new Binding("Image", dsRadiografias, "RADIOGRAFIAS.rad_imagen");
//ImageBinding.Format += new ConvertEventHandler(this.PictureFormat);

I was trying with this conversion routine, with no good results:

void PictureFormat(Object sender, ConvertEventArgs e)
      Byte[] img = (Byte[]) e.Value;
      // Perform the conversion
      MemoryStream ms = new MemoryStream();
      int offset = 0; // should be 0
      ms.Write(img, offset, img.Length - offset);
      Bitmap bmp = new Bitmap(ms);

      // Writes the new value back
      e.Value = bmp;

World only exists into your mind.
Old August 20th, 2004, 01:02 AM
Authorized User
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts

Sorry, there is no problem. I was fighting with another error, but I got confused for the null values when I tried to insert new records.

Similar Threads
Thread Thread Starter Forum Replies Last Post
XML File & Images DennyLoi XML 4 November 4th, 2007 12:58 PM
Uploading & retriving Images From Database aaaboye Classic ASP Basics 1 February 20th, 2007 04:03 PM
Dynamic Images & Go To Detail Page malhyp Dreamweaver (all versions) 1 January 27th, 2006 06:10 AM
bindings & date format miguel.ossa C# 12 August 28th, 2004 06:23 AM
Loading Images & Interact with Outlook wasaan SQL Server ASP 1 August 4th, 2003 06:35 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.