We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Image Resolution when displaying in a GridGroupingControl

Thread ID:

Created:

Updated:

Platform:

Replies:

128469 Jan 25,2017 01:45 AM UTC Feb 13,2017 12:43 PM UTC Windows Forms 5
loading
Tags: GridGroupingControl
George Busby
Asked On January 25, 2017 01:45 AM UTC

I am able to display an image in a cell that is based on a .JPG file on my local machine. The problem is the image resolution is very low. When I enlarge the image the picture becomes pixalated. Does the GridCellTypeName.Image have a defaulted image resolution? Can the resolution be modified? The images I am displaying are pictures of people and would like to be able to display in a size that makes it easy to see the person,but I also need the resolution to be good enough so the image does not become pixalated.

Mohanraj Gunasekaran [Syncfusion]
Replied On January 25, 2017 10:50 AM UTC

Hi George, 

Thanks for Syncfusion products. 

In order to load the image without pixelate while resizing the image column, you can use the ImageList.ImageSize property and ImageSizeMode property. Please refer the below code snippet and refer the below attached sample, 
 
Code snippet 
ImageList image = new ImageList(); 
image.ImageSize = new System.Drawing.Size(256, 184); 
 
 
this.gridGroupingControl1.TableDescriptor.Columns["ImageColumn"].Appearance.AnyRecordFieldCell.ImageSizeMode = GridImageSizeMode.AutoSize; 
 
 
 


Sample link: GridGroupingControl 

Regards, 
Mohanraj G. 


George Busby
Replied On January 28, 2017 03:08 PM UTC

I tried setting the values as you suggested the images still have a resolution issue. I am using the Image.FromFile(path) in load the file into an ImageList. I set the size to 256 and set the ImageSizeMode to AutoSize. I attached a screen shot to show what the images look like.



Attachment: Example_e6df36bc.zip

Mohanraj Gunasekaran [Syncfusion]
Replied On January 30, 2017 12:55 PM UTC

Hi George, 

Sorry for the inconvenience caused. 

We could able to understand your scenario. If the Image CellType as inconvenient to load the image, please use the Control CellType for GridControl and load the PictureBox control in Control CellType with the image. Please refer the below code snippet and refer the attached sample, 

Code snippet 
this.gridGroupingControl1.TableDescriptor.Columns["ImageColumn"].Appearance.AnyRecordFieldCell.CellType = GridCellTypeName.Control; 
this.gridGroupingControl1.QueryCellStyleInfo += gridGroupingControl1_QueryCellStyleInfo; 
PictureBox box = new PictureBox(); 
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) 
{ 
    if (e.TableCellIdentity != null && e.TableCellIdentity.Column != null 
        && e.TableCellIdentity.Column.Name == "ImageColumn" && e.TableCellIdentity.TableCellType != GridTableCellType.ColumnHeaderCell) 
    { 
        e.Style.CellType = GridCellTypeName.Control; 
        if (File.Exists(e.Style.CellValue.ToString())) 
        { 
            box.Image = Image.FromFile(e.Style.CellValue.ToString()); 
            e.Style.Control = box; 
        } 
                 
    } 
} 

Screenshot 
 

Sample link: GridGroupingControl 

Regards, 
Mohanraj G. 
 


George Busby
Replied On February 11, 2017 04:42 PM UTC

Thank you for the information. I am able to get the image to display in a cell and the resolution is what I needed. However, the system is constantly running through the QueryCellStyleInfo function ( mouse over the area, scrolling, resizing the cells) and eventually uses up all of the system memory.  I attempted to check inside of the QueryCellStyleInfo function to see if the cell has already been set with an image, but the data that is set inside of the QueryCellStyleInfo function is not stored. I tried to check to see if e.style.control has been set but it always comes back as "Nothing", (even for a cell that is already displaying an image) so the system resets the image from file.

Is there a way to determine if a cell has already been set with the PictureBox control and has an image displayed?

Mohanraj Gunasekaran [Syncfusion]
Replied On February 13, 2017 12:43 PM UTC

Hi George, 

Thanks for your update. 

We can understand your scenario. This event will get triggered for each cell before a GridTableControl starts painting and allows to customize the display of cells. This event only triggered recursively for the cells that are being displayed on screen (only on demand) 

When mouse over or resize of form causes some cells to be drawn or redrawn which causes triggering of this event. So with proper conditional statements in the event, the unnecessary execution of the code can be avoided.   
Please refer the below link, 
 
In order to overcome this scenario, You can use the Byte[] DateType for image column and convert the image as byte[] format in DataTable. Please refer the below code example and refer the below attached sample,    
 
Code snippet 
for (int l = 0; l < 5; l++) 
{ 
    DataRow dr = dt.NewRow(); 
    dr[0] = name1[r.Next(0, 5)]; 
    dr[1] = "E" + r.Next(30); 
    dr[2] = new DateTime(2012, 5, 23); 
    dr[3] = country[r.Next(0, 5)]; 
    dr[4] = city[r.Next(0, 5)]; 
    dr[5] = scountry[r.Next(0, 5)]; 
    dr[6] = r.Next(1000, 2000); 
    dr[7] = r.Next(10 + (r.Next(600000, 600100))); 
    Byte[] imageArray = System.IO.File.ReadAllBytes(FindFile(@"flower" + l % 3 + ".jpg")); 
    dr[8] = imageArray; 
    dt.Rows.Add(dr); 
} 
return dt; 
Screen shot 
 


Sample link: GridGroupingControl 


Regards, 
Mohanraj G 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;