Wednesday 15 February 2012

Binding ImageLocation to a PictureBox in C#

The sample code for Binding ImageLocation property of the PictureBox to a column in Database is :

picturebox1.DataBindings.Add("ImageLocation", Datasouce, "ImagePath",true);

ImageLocation  --- property of the PictureBox Control
Datasource       --- DataTable that contains the ImagePath
ImagePath        --- Column Name of the Image paths in the DataTable
true                  --- Enables the formatting of the value as True

There are 5 more overloads for the Function. But this one works fine for most of the cases. Intellisense of Visual Studio will give you additional information about of the other overloads when you type this code.