Hi,
I am trying my best since morning to fix the below issue where i need a Grid Tree control to display an image along side a text in cells of a particular row.I am setting this in the Query Cell Info and based on the key,i try to set the Style of the Cell with the image.I am doing as below.But what ever i try,the Image comes in a Bloated way and stretches along with the column.The image size is small but when it is displayed in the cell,it is showing huge and expanded.What am i doing wrong here
Image newImg = new Image(); BitmapImage mbitmap = new BitmapImage();mbitmap.BeginInit();
mbitmap.UriSource =
new Uri(@"C:\Cash_Monitor_CodeBase\a490560_CM4.3\vob_fi_trading\src\applications\FMRCo.Fi.CashMonitor\FMRCo.Fi.CashMonitor\Resources\warning.png");mbitmap.EndInit();
newImg.Source = mbitmap;
newImg.RenderSize =
new Size(2, 2);style.ImageMargins =
new CellMarginsInfo(0, 2, 100, 2);style.ImageList =
new System.Collections.ObjectModel.ObservableCollection<Image>(new List<Image>() { newImg });style.ImageIndex = 0;
style.ImageContentStretch =
ImageContentStretch.Absolute;style.Image.Stretch =
Stretch.None;Hi Amitha
Thank you for contacting
Syncfusion support,
We have analyzed your query and we could find that you have
set the ImageContentStretch to absolute. If we set
this as absolute, then our GridDataControl
renders the image by using the Exact Image Size(Pixel). Here, I recommend you to use
the ImageContentStretch.Uniform to achieve the requirement.
Please refer the below code snippet for reference:
Code Snippet:
void InternalGrid_QueryCellInfo(object
sender, GridQueryCellInfoEventArgs e) {
if (e.Style.RowIndex == 3)
{
Image image = new
Image();
BitmapImage mbitmap = new BitmapImage();
mbitmap.BeginInit();
mbitmap.UriSource = new Uri(@"image
location");
mbitmap.EndInit();
image.Source = mbitmap;
image.RenderSize = new Size(2, 2);
e.Style.Image = image;
e.Style.ImageMargins = new CellMarginsInfo(0, 2, 100, 2);
e.Style.ImageIndex = 0;
e.Style.ImageContentStretch = ImageContentStretch.Uniform;
e.Style.Image.Stretch
= Stretch.Uniform;
} } |
We have created the sample based on your requirement and you
can find the sample from the below location:
Sample: Image.zip
Please let us know, if you have any query.
Thanks,
Shakul Hameed