Anthoni Posted September 21, 2014 Posted September 21, 2014 Hi, I am trying to display some information to the user (a list of Youtube videos to be precise) and I want to display the Thumbnail as well. How do I get the picture displayed in a UniDBGrid? I thought, originally about creating a Frame and placing a normal UniImage on there and then displaying that BUT then I realized I needed to be able to actually allow the user to sort. Hence the Grid Quote
Administrators Farshad Mohajeri Posted September 21, 2014 Administrators Posted September 21, 2014 UniDBImage? Quote
Anthoni Posted September 21, 2014 Author Posted September 21, 2014 UniDBImage? OK, so I might not fully understand, or explained myself properly. I am grabbing the Youtube information via their API system, performing some calculations and then storing the results in a Generic List. The list contains TYoutubeResults class and in that class I have a property called ThumbURL which is a string to the thumbnail of said video. Now in order to show this in a DBGrid I am aware I need to populate a DBMemTable and then add that as Datasource for the DBGrid, however given that the URL is only a string, how do I tell it to display (fetch the image) instead of displaying a string? Hopefully that's explained it a bit better Quote
Administrators Farshad Mohajeri Posted September 21, 2014 Administrators Posted September 21, 2014 There are events which will enable you to do this. Please db image demo. Quote
Anthoni Posted September 21, 2014 Author Posted September 21, 2014 There are events which will enable you to do this. Please db image demo. I don't have that demo listed. I have DBDemo but that is from a Datasource and Blobs Can you send me it please, or attach it here. Quote
Administrators Farshad Mohajeri Posted September 21, 2014 Administrators Posted September 21, 2014 Grid image demo or something like that Quote
zilav Posted September 22, 2014 Posted September 22, 2014 however given that the URL is only a string, how do I tell it to display (fetch the image) instead of displaying a string? Create calculated widestring field, and use html tags DataSet.FieldByName('calc_youtube').AsString := Format('<img src="%s">', [DataSet.FieldByName('youtube_url').AsString]); Quote
Anthoni Posted September 22, 2014 Author Posted September 22, 2014 Create calculated widestring field, and use html tags DataSet.FieldByName('calc_youtube').AsString := Format('<img src="%s">', [DataSet.FieldByName('youtube_url').AsString]); Would I still use the DBGrid FieldImageURL event ? Basically I am not 100% sure where to put that code. Quote
zilav Posted September 22, 2014 Posted September 22, 2014 Nope. You put it in CalcFields event of DataSet. Quote
Administrators Farshad Mohajeri Posted September 22, 2014 Administrators Posted September 22, 2014 FieldImageURL is enough. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.