How can you show an image in a column in the Jiwa Grid?
More specifically I am looking to do something similar to the the list maintenance found viewtopic.php?f=27&t=498 but where one of the database fields would be a blob/image.


grdLines.AddColumn("Image", new FarPoint.Win.Spread.CellType.ImageCellType(), "Image", 20, false, true, true, true);private void grdLines_ButtonClicked(object sender, FarPoint.Win.Spread.EditorNotifyEventArgs e)
{
FarPoint.Win.Spread.Column column = grdLines.ActiveSheet.Columns[e.Column];
string RecID = grdLines.get_GridText("RecID", e.Row).ToString();
bool isNew = (RecID == null || RecID.Trim().Length == 0);
if (column.Tag.ToString() == "Bin")
{
if (RecID.Trim().Length > 0)
{
BusinessLogic.Remove(BusinessLogic[RecID]);
}
}
else if (column.Tag.ToString() == "ImageLookup")
{
JiwaFinancials.Jiwa.JiwaApplication.Image.Image image = null;
if (isNew)
{
string[] files = BrowseForImageFiles(true);
if (files != null)
{
foreach (string filename in files)
{
image = Manager.CollectionItemFactory.CreateCollectionItem<JiwaFinancials.Jiwa.JiwaApplication.Image.Image>();
image.ImageBinary = System.IO.File.ReadAllBytes(filename);
image.Name = System.IO.Path.GetFileNameWithoutExtension(filename);
BusinessLogic.Add(image);
}
}
}
else
{
image = BusinessLogic[RecID];
string[] files = BrowseForImageFiles(false);
if (files != null)
{
image.ImageBinary = System.IO.File.ReadAllBytes(files[0]); ;
}
}
}
}
public string[] BrowseForImageFiles(bool MultiSelect)
{
System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog
{
Title = "Select Image",
Filter = @"All Files (*.*)|*.*|All Pictures (bmp,gif,jpg,png,wmf)|*.bmp;*.gif;*.jpg;*.png;*.wmf|Bitmaps (*.bmp,*.dib)|*.bmp;*.dib|GIF Images (*.gif)|*.gif|JPEG Images (*.jpg)|*.jpg|PNG Images (*.png)|*.png|Metafiles (*.wmf)|*.wmf",
Multiselect = MultiSelect,
InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)
};
if (openFileDialog.ShowDialog(this.Form) == System.Windows.Forms.DialogResult.OK)
{
return openFileDialog.FileNames;
}
return null;
}
grdLines.set_GridText("Image", Row, item.ImageBinary);
grdLines.ActiveSheet.Rows[Row].Height = grdLines.ActiveSheet.Rows[Row].GetPreferredHeight();


SBarnes wrote:how can I get the image column wide changing the width percentage makes no difference?

float pheight = grid.ActiveSheet.Rows[i].GetPreferredHeight();
if (pheight > 500)
{
pheight = 500;
}
grid.ActiveSheet.Rows[i].Height = pheight;
float pwidth = grid.ActiveSheet.Columns["Image"].GetPreferredWidth();
if (pwidth > 500)
{
pwidth = 500;
}
grid.ActiveSheet.Columns["Image"].Width = pwidth;

Return to Technical and or Programming
Users browsing this forum: No registered users and 1 guest