Recently the project needs to display a series of pictures of the product, intends to use CardView to show that, because the first use, encountered many problems, found that the resources on the Internet is very small, so put their own a little bit of practical experience to summarize for themselves and everyone later reference.
1, select CardView, the original Girview converted to CardView, such as
The effect is as follows:
2, the control by default is vertical arrangement, if you want to change to horizontal arrangement, change the property maximumcardcolumns (the number of cards allowed to arrange horizontally) and maximumcardrows (the number of cards allowed to be arranged vertically).
I set here as: Maximumcardcolumns:-1, maximumcardrows:1, effects such as;
3, to use the card, most of the situation is to display pictures. How to show it? Add an object that stores the picture (I'm here to add the field of the image type directly in the data source), and then change the field's Columnedit type to Pictureedit and named Rowpicture, as
4, also found that the size of the picture is limited, change the CardView (card height adaptive to adapt to the height of the picture) and rowpicture (set the height of the picture) two places of the property can be,
CardView:
Rowpicture:
Effects such as:
5, the layout problem solved, the other needs to adjust, in fact, there are properties, here is just a demonstration. How to download the image according to the URL to display, the main code is posted here:
var client = new WebClient ();
Client. downloaddatacompleted + = client_downloaddatacompleted;
Client. DownloadDataAsync (The New Uri (IMG). URL));
private void Client_downloaddatacompleted (object sender, DownloadDataCompletedEventArgs e)
{
Try
{
Image img = image.fromstream (new MemoryStream (E.result));
······
}
catch (Exception ex)
{
······
}
}
This is almost the problem, prompt, note the picture is cached to improve performance. "Transfer from CSDN, URL: http://m.blog.csdn.net/blog/yang472024191/4053632"
Go DevExpress Gridcontrol A little summary of the use of CardView