Dynamic rowheight in Foxpro grid

Hi Foxpro Experts,

In my VFP9 application I'm using a data grid with a memo field in a column.
This column contains an editbox component instead of the normal textbox component (and the Sparse property is set to false).

My question is: how can I make the rowheight of the data grid dynamic?  For example, if the memo field contains 1 line, I would like to see a rowheight of 1 line, when the memo field contains 4 lines, I would like to see a row height of 4 lines.  This should be a dynamic height, so each row can have a different height.

Can anyone tell me how I can realize this in VFP9, or is this completely impossible?

Thanks,
JDN
LVL 1
JDNAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pcelbaCommented:
This is partially possible. The problem is you cannot have rows of different sizes... But you may change RowHeight property for all grid rows depending on the current record memo field size.

You may implement it in AfterRowColChange event of the grid as it is shown in the code snippet. You should define your own minimum and maximum row size and you may enhance the code by Row change check to avoid useless MEMLINES() calculation if just the column is changed.

*-- AfterRowColChange event:
LPARAMETERS nColIndex
LOCAL lnHeight
lnHeight = MIN(MAX(25, MEMLINES(YourMemoFieldName) * 18 + 7), 60)
IF THIS.RowHeight <> lnHeight
  THIS.RowHeight = lnHeight
ENDIF
RETURN

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CaptainCyrilFounder, Software Engineer, Data ScientistCommented:
If you are displaying your data, why don't you try to use a WebBrowserControl which can display HTML files and this way you don't need to worry about height. You can also have editboxes on HTML for editing but that will take extra work.
0
Olaf DoschkeSoftware DeveloperCommented:
If you take pcelbas Code the grid will be rather bumpy, I wouldn't do it that way. I'd rather display a shortened text, if it has more than can be displayed in a single row. Add an ellipsis (...) at the end of the first line and rather display the full memo value outside of the grid in a seperate Editbox.

Bye, Olaf.
0
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

JDNAuthor Commented:
Thanks for the comments.
I understand it's impossible in Foxpro to have a dynamic rowheigth, indeed rows of different size.
I've seen this in other applications (created with e.g. Delphi) and I hoped there was a way to achieve this in Foxpro.
0
Olaf DoschkeSoftware DeveloperCommented:
Well, using another grid (ActiveX) this would be possible, but you wouldn't have the comfort of foxpro's grid's RecordSource. The one you can have, the other you can't. Even if it would be possible, I'd consider my suggestion looking clean and good. It's not that hard to write a function limiting a memo content to the first line. As a start you Select Left(memofield,254) as singleline for the grid column and then you could misuse DisplayPath() to shorten that for display, eg have a controlsource of (DisplayPath(singleline)). And bind memofield to a separate Editbox.

Bye, Olaf.
0
Olaf DoschkeSoftware DeveloperCommented:
In fact forget DisplayPath as it auto adds CurDir, but take a look at the idea behind it.

Bye, Olaf.
0
EE_AutoDeleterCommented:
I've requested that this question be deleted for the following reason:

No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Not enough information to confirm an answer.

If you feel this question should be closed differently, post an objection and a moderator will read all objections and then close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

Experts-Exchange Auto Deleter
0
pcelbaCommented:
You may split points among ID: 24469149, ID: 24470146, ID: 24470321
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
FoxPro

From novice to tech pro — start learning today.