Solved

Memo field in DBGrid or StringGrid?

Posted on 1998-09-15
5
1,511 Views
Last Modified: 2010-05-18
Hi,

I need to put a memo of some kind in a grid so that you can edit the memo field in the grid (Delphi 4).  I know that components like InfoPower are the best way to do this but is there another way?

Thank you,
/MP
0
Comment
Question by:mikepj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Expert Comment

by:Greedy
ID: 1339755
When you say memo in a grid what do you want?
1) when the user enters the field a membo box pops up and then goes away on field's loss on focus

2) for the user to be able to type and view memo data from the grid.  If this is what you want do you want the boxes of the other fields to expand with the memo field's box or do you want the memo filed to wrap around the record or something like that?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339756
Here is what you do:-)

In the OnDrawCell() of the string grid....
---------
procedure TForm1.SGDrawCell(Sender: TObject; Col, Row: Integer;
  Rect: TRect; State: TGridDrawState);
begin
     if(col = 1)and(row = 1) then
     with Memo1 do
     begin
          Parent := SG;
          Left := Rect.Left;
          Top := Rect.Top;
          Width := Rect.Right div 2;
          Height := Rect.Bottom div 2;
     end;
end;
-----------
Regards,
Viktor Ivanov
0
 
LVL 2

Author Comment

by:mikepj
ID: 1339757
Thank you for your reply,

Although on the surface, this answer does work, there are a number of problems which come up when I do this.  Things like:

- problems with focus control
- making it clear to the user what's happening
- dealing with times when it is not the top row item that is being edited

I am hoping to have a component that does this in a nice way rather than something that is kind of a mess.

/MP

0
 

Accepted Solution

by:
huizhang earned 100 total points
ID: 1339758
mikepj

It is very simple to display or edit a memo field in TDBGrid.

In design mode do following;
1. doulble click on your table icon, add your fields(include the
   memo field (here is called 'MemoField')
2. hilight the memo field
3. in the Object Inspector, add two events for the memo field
   OnGetText and OnSetText, coded as:

procedure TForm1.Table1MemoFieldGetText(Sender: TField; var Text: String;
  DisplayText: Boolean);
begin
  Text:=Table1MemoField.AsString;
end;

procedure TForm1.Table1MemoFieldSetText(Sender: TField; const Text: String);
begin
  Table1MemoField.AsString:=Text;
end;

0
 
LVL 2

Author Comment

by:mikepj
ID: 1339759
Thank you for your answer.  This doesn't solve my main problem per se but did provide a useful bit of information.  I ended up doing a bit of a crazy solution to the problem using a memo which becomes visible superimposed over the grid when the memo field is entered.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question