Is there any effort by core developers to enable DBgrid to show Memo fields? lazarus / 16-Databases ---------------------------------------------------------------------- snorkel · 2013-03-08 16:51 Just wondering if there was any effort to enhance the DBGrid to automatically show and edit memo fields instead of show [memo] This is one of the biggest annoyances of using the DGbrid in Delphi and it would be super nice to have the Lazarus DBgrid out do the Delphi one in yet another way. If not maybe we could add this to the Grids reference page: http://lazarus.freepascal.org/index.php/topic,16300.0.html ---------------------------------------------------------------------- BigChimp · 2013-03-09 06:40 Go ahead, be my guest and add that info to the grids reference page AFAIK, there is no effort to show the contents of memo fields... but you could always raise a bug report in the issue tracker. ---------------------------------------------------------------------- teos · 2013-03-28 22:46 automatically showing memo fields in a DBgrid IMHO is not implemented because of a fairly simple reason: speed. showing memo fields with large content would slow down fetching/showing data dramatically. ---------------------------------------------------------------------- Dibo · 2013-03-28 23:09 I think this is good that [MEMO] is showing, programmer know that he must decide what to do with this kind of field. Especially when there is easy way to handle it. If you are sure that string is not to big to have affect on efficient, you can just add field event OnGetText: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.OnGetMemoText(Sender: TField; var aText: string;  DisplayText: Boolean);begin  if DisplayText then    aText := Sender.AsString;end; I'm not sure but second reason is that some of databases (TSQLQuery is wrapper for postgres, sqlite, mysql etc) can store binary data in TEXT fields, so [MEMO] doesn't mean that there is a big text only. But I'm wondering about Size field property. It has affect on VARCHAR field types, but it could also on MEMO fields. Why if size if <> 0 then [MEMO] is still showing? ---------------------------------------------------------------------- u2o · 2013-04-06 16:16 Hi all! I´m working on a runtime menu, loading items and their icons from a sqlite3 db. I save the icons (png format) on a blob field After, in the code load each icon with TMemoryStream -> TPortableNetworkGraphic -> TImageList. Maybe it's posible... insert TPicture controls on the Grid rows to show images... ---------------------------------------------------------------------- u2o · 2013-04-06 16:17 and the db fields ---------------------------------------------------------------------- BigChimp · 2013-04-29 11:49 Please open a new thread when asking about a new subject. Also please always specify your Lazarus, FPC, OS version. See link in signature below. ---------------------------------------------------------------------- marcov · 2013-04-29 13:29 Quote from: Dibo on March 29, 2013, 12:09:57 amI think this is good that [MEMO] is showing, programmer know that he must decide what to do with this kind of field. Especially when there is easy way to handle it. If you are sure that string is not to big to have affect on efficient, you can just add field event OnGetText: Usually I only copy the first line of the  memo filed in the grid. Otherwise you get funny characters for the crlf pairs. I've put the method in the same datamodule as the connection, and a short procedure that walks the form tree and sets it to all twidememofields. (Disclaimer: the above is Zeos, not sqldb experience) ---------------------------------------------------------------------- u2o · 2013-04-29 15:28 Quote from: Dibo on March 29, 2013, 12:09:57 amWhy if size if <> 0 then [MEMO] is still showing? If you use a TMemoryStream to load the Memo field, you can use: Code: [Select]var   ms : TMemoryStream   blobF : TBlobField; Begin   ms := TMemoryStream.Create;   blobF := TBlobField( SQLQueryA.FieldByName('icon') );   blobF.SaveToStream(ms);   If (ms.Size > 0) then begin           // The MemoryStream has data     // your code for this condition   end; end; ---------------------------------------------------------------------- BigChimp · 2013-04-29 15:31 @u2o: I see no code interacting with a grid there. How would the contents of the memory stream be displayed on the grid? ---------------------------------------------------------------------- u2o · 2013-04-29 19:51 Quote from: BigChimp on April 29, 2013, 05:31:32 pm@u2o: I see no code interacting with a grid there. How would the contents of the memory stream be displayed on the grid? Yes, I use arrays to load the data in a TreeView, or in a menu. I haven't yet tested directly in the DBGrid. But is interesting, the ways that can be found to implement this code. I started programming with Bash in Linux and Batch on Win. Then I move to VB6, and today I'm with Lazarus and the versatility that i found is awesome! ---------------------------------------------------------------------- snorkel · 2013-05-07 16:05 Quote from: teos on March 28, 2013, 11:46:42 pmautomatically showing memo fields in a DBgrid IMHO is not implemented because of a fairly simple reason: speed. showing memo fields with large content would slow down fetching/showing data dramatically. I don't think that's the reason, you can have pretty large varchars and they work fine. plus, you can use beginupdate/endupdate so the UI does not update while the grid loads. Seems like it's just a carry over from the delphi dbgrid. ---------------------------------------------------------------------- snorkel · 2013-05-07 16:19 why couldn't there just be a option to show memo fields?  That way users with speed issues would not have to use it? ---------------------------------------------------------------------- taazz · 2013-05-07 16:25 The memo field can hold various type of data including html, rtf, and other formated text. Since the DBGrid has no text formating abilities it would unwise to allow something to show that makes no sense to the end user by default. That is why you have to make a conscious decision to show data on a dbgrid. It is better that way, making sure that you have full control over the result instead of getting unwanted results. ---------------------------------------------------------------------- snorkel · 2013-05-13 14:53 Quote from: taazz on May 07, 2013, 06:25:32 pmThe memo field can hold various type of data including html, rtf, and other formated text. Since the DBGrid has no text formating abilities it would unwise to allow something to show that makes no sense to the end user by default. That is why you have to make a conscious decision to show data on a dbgrid. It is better that way, making sure that you have full control over the result instead of getting unwanted results. So can a varchar, I don't see the difference except that a memo can be of unlimited size. Most databases have a separate blob type for handling data other than text and they have a type for for big text, i.e. PostreSQL has the text type. In most RDBMS the text type at it's base is a blob, but a blob meant for storing text. So I really disagree with the whole [MEMO] thing and think the DBgrid should handle it in a better way, The Lazarus DBgrid is already considerably better than the Delphi DBgrid, so why keep the [MEMO] behavior from the stock delphi DBgrid?  The lazarus DBgrid shows booleans as checkboxes automaticly, why not [MEMO] Just my opinion on the matter. Later, Snorkel ---------------------------------------------------------------------- BigChimp · 2013-05-13 15:07 Agreed up to a point. You could write a patch that checks the field type (e.g. memo subtype text for Firebird) for types that certainly contain text, then display the text instead of [MEMO]. Append that to a bug report and who knows, it may get included.