c# - Fit image into datagridview column -
i've datagridview of height , width 300x300 size. i'm reading image memory stream. want resize image datagridview column such fit in it. i've following code
this code read image database
byte[] img = (byte[])(datareader[5]); memorystream ms = new memorystream(img);
code adding items in datagridview
datagridview1.rows.add( image.fromstream(ms));
above code crops image , display 300x300 size of image.
you can use datagridviewimagecolumn
has imagelayout
property,
byte[] img = (byte[])(datareader[5]); memorystream ms = new memorystream(img); datagridviewimagecolumn imagecol = new datagridviewimagecolumn(); imagecol.headertext = "test1"; datagridview1.columns.add(imagecol); imagecol.imagelayout = datagridviewimagecelllayout.stretch; // trick datagridview1.rows.add(image.fromstream(ms));
hope helps,
Comments
Post a Comment