For:
- 'Custom Data Type': System.Drawing.Bitmap
- 'Serialize Data?': selected.
Code generated automatically for the SF:
/// <summary>
/// Fotografia
/// </summary>
/// <remarks></remarks>
[Browsable(false),
BusinessFieldDisplayInEditor(),
Description("Fotografia"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public System.Drawing.Bitmap Foto
{
get
{
try
{
return (System.Drawing.Bitmap)this.BinaryFormatter.Deserialize(new
MemoryStream((Byte[])this.CurrentRow["Foto"]));
}
catch
{
return null;
}
}
set
{
if(value != null)
{
MemoryStream loStream = new MemoryStream();
this.BinaryFormatter.Serialize(loStream, value);
this.CurrentRow["Foto"] = loStream.ToArray();
}
else
this.CurrentRow["Foto"] = new byte[0]; ;)
}
}
This alteration is necessary to be able to exclude an image.
private void cmdExcluiFoto_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Deseja realmente excluir a foto?", "Atenção",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2,
MessageBoxOptions.DefaultDesktopOnly) == DialogResult.No)
return;
picFoto.Image = null;
tbCadastroPFBO1.Foto = null; ;)
}
Rogério Mauri