Skip to content

Commit 51c1106

Browse files
ES-976509 - Resolve Issues in Public Syncfusion Code Examples for DataGrid XAML Controls
1 parent 5501a4d commit 51c1106

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

ColumnLoadedWithImages.png

207 KB
Loading

README.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,43 @@
1-
# How to load the image without reducing the resolution
2-
This example demonstrates that how to load the image without reducing the resolution
1+
2+
# How to Load the Image without Reducing the Resolution in WinForm GridControl?
3+
4+
This example demonstrates that how to load the image without reducing the resolution in [WinForms GridControl](https://www.syncfusion.com/winforms-ui-controls/grid-control).
5+
6+
To maintain the image resolution, convert the image as byte format and use Byte datatype for the image column in the grid. By default, when the image loaded in the grid cell is resized using the [ImageSize](https://learn.microsoft.com/pt-br/dotnet/api/system.windows.forms.imagelist.imagesize?redirectedfrom=MSDN&view=netframework-4.7.2) property, the resolution of the image gets affected.
7+
8+
``` csharp
9+
private DataTable CreateTable()
10+
{
11+
dt.Columns.Add("Name");
12+
dt.Columns.Add("Id");
13+
dt.Columns.Add("Date");
14+
dt.Columns.Add("Country");
15+
dt.Columns.Add("Ship City");
16+
dt.Columns.Add("Ship Country");
17+
dt.Columns.Add("Freight");
18+
dt.Columns.Add("Postal code");
19+
dt.Columns.Add("ImageColumn", typeof(byte[]));
20+
21+
for (int l = 0; l <= gridControl1.RowCount; l++)
22+
{
23+
DataRow dr = dt.NewRow();
24+
dr[0] = name1[r.Next(0, 5)];
25+
dr[1] = "E" + r.Next(30);
26+
dr[2] = new DateTime(2012, 5, 23);
27+
dr[3] = country[r.Next(0, 5)];
28+
dr[4] = city[r.Next(0, 5)];
29+
dr[5] = scountry[r.Next(0, 5)];
30+
dr[6] = r.Next(1000, 2000);
31+
dr[7] = r.Next(10 + (r.Next(600000, 600100)));
32+
//Adding image as Byte[] array.
33+
Byte[] imageArray = System.IO.File.ReadAllBytes(FindFile(@"flower" + l % 3 + ".jpg"));
34+
dr[8] = imageArray;
35+
dt.Rows.Add(dr);
36+
}
37+
return dt;
38+
}
39+
```
40+
41+
The screenshot below illustrates the images without reducing the resolution.
42+
43+
![GridControl column loaded with Images](ColumnLoadedWithImages.png)

0 commit comments

Comments
 (0)