Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 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 October 8th, 2005, 02:56 AM
Registered User
 
Join Date: Sep 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Populating a DataGridViewImageColumn.

Hi, I have a problem with the following code, I need to read three cells and build up an ImagePath and add it to a root Path, with that path I need to populate the ImageColumn. When the code runs all I get are blank Image Boxes.

        private DataSet InitializeDataGridViewer(string connectionString)
        {
            string commandString = "Select * From SMASTER";

            OleDbDataAdapter DataAdapter = new OleDbDataAdapter(commandString, ConnectionString);
            DataSet DataSet = new DataSet();
            DataAdapter.Fill(DataSet, "SMASTER");
            dataGridView1.DataSource = DataSet.Tables["SMASTER"].DefaultView;
            DataGridViewImageColumn imageColumn;
            imageColumn = new DataGridViewImageColumn();
            imageColumn.HeaderText = "1st Image";
            imageColumn.Name = "1stImage";
            dataGridView1.Columns.Add(imageColumn);

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                try
                {
                    RawImagePath = row.Cells["PATH"].Value.ToString() +
                    "\\" +
                    row.Cells["BATCH_NO"].Value.ToString() +
                    row.Cells["STARTID"].Value.ToString() +
                    ".tif";
                }
                catch
                {
                    continue;
                }
                string fullPath = imagePaths[0] + "\\" + RawImagePath;
                string newfullstring = fullPath.Substring(10, fullPath.Length - 10);
                Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
                Bitmap myBitmap = new Bitmap(newfullstring);
                Image myThumbnail = myBitmap.GetThumbnailImage(40, 60, myCallback, IntPtr.Zero);
                row.Cells["1stImage"].Value = myThumbnail;
                //row.Cells["1stImage"].Value = imageColumn.Image = myThumbnail;
                dataGridView1.Update();
                Application.DoEvents();
            }
            return DataSet;
        }
        public bool ThumbnailCallback()
        {
            return false;
        }



Now when I run the version with the commented lines swaped, When run, instead of a different image (According to the path), all I get is the same image in each cell.

Any help would be welcome.
Thanks in advance,
Robert Kelly.






Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: DATAGRID POPULATING emeka VB Databases Basics 0 April 28th, 2007 08:06 PM
Populating DataGrid emeka VB Databases Basics 0 April 28th, 2007 07:13 PM
Populating a DataGridView sagarbhargava Visual Basic 2005 Basics 2 April 26th, 2007 07:03 AM
Populating new table young20 Access VBA 1 November 15th, 2006 08:20 AM
Populating a collection jaucourt VB.NET 2002/2003 Basics 3 March 1st, 2004 12:55 PM





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