Topic: Multiline text box

Hi there, is there a way to insert a multiline text box in a project? And if yes, how to fill in the line breaks?
Using single line text boxes is just a chore when you want to explain something or just display a long text.

2 (edited by mr_d 2015-01-19 12:47:47)

Re: Multiline text box

isn't his what the http://myvisualdatabase.com/help_en/script/memo.html component is for?

using this component you do not need to add line breaks as each line is added using the Lines.Add function.

http://myvisualdatabase.com/help_en/components/memo.png

Dennis

Re: Multiline text box

I have actually no clue what this component is for, I was unable to write any text in it during project edition.

What I would like is a component which allows me to fill in free text like for a changelog or even this forum when you reply. I could edit it but not the users.

Re: Multiline text box

tcoton wrote:

I have actually no clue what this component is for, I was unable to write any text in it during project edition.

What I would like is a component which allows me to fill in free text like for a changelog or even this forum when you reply. I could edit it but not the users.

In the current version you can do it using a script, I have made a example for you.
Also you should enable a property ReadOnly of component Memo1

Post's attachments

Attachment icon Multiline textbox fill by script.zip 2.24 kb, 604 downloads since 2015-01-19 

Dmitry.

5 (edited by mr_d 2015-01-19 14:00:11)

Re: Multiline text box

i had already started an example when Dmitry replied, but completed it as i didn't want it to go to waste.
so please have a look at this example as well as the one posted above by the developer.

the compiled version and sqlite.dll file has been removed to reduce the archive size.

Post's attachments

Attachment icon memo_test.zip 2.59 kb, 577 downloads since 2015-01-19 

Dennis

Re: Multiline text box

Thanks to you guys, both solution are pretty interesting.

I actually would need a mix of both solution: displaying a read only form which automatically loads a separate text file , so I would not need to edit any script afterward nor have to manage any button. Just editing a text file would suffice to update the information displayed.


I think I would use this in the script:

procedure Form1_OnShow (Sender: string; Action: string);
begin
     form1.memo1.lines.loadfromfile('test.txt');
end;


@mr_d We may ask ourself about the use of a read only checkbox since anyone can disable it smile
       I will keep your version for text editing though, thanks a lot

A more elegant way of doing it would be to save the text in a table and load this text into the memo, so the text would not be easily edited by end users.

I wonder if it is possible to format the text inside this multiline textbox?

Re: Multiline text box

tcoton wrote:

I wonder if it is possible to format the text inside this multiline textbox?


This component not supported formating the text, but I planned add advanced version of Memo with formating.

Dmitry.

Re: Multiline text box

Sounds good, thanks Dmitry.

How would do to save and load the text from database instead of an external text?

Re: Multiline text box

tcoton
Example:

// save text to DB
procedure Form1_Button2_OnClick (Sender: string; var Cancel: boolean);
var
    s: string;
begin
    s := ReplaceStr(Form1.Memo1.Text, '''', ''''''); // for quotes
    SQLExecute('REPLACE INTO base (id, info) VALUES (1, '''+s+''')');
end;

// load text from DB
procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
begin
    Form1.Memo1.Text := SQLExecute('SELECT info FROM base WHERE id=1');
end;

Also you can download the example:

Post's attachments

Attachment icon Multiline textbox fill by script from DB.zip 3.71 kb, 601 downloads since 2015-01-23 

Dmitry.

Re: Multiline text box

Thanks, this does the trick, however, speach marks  ( " ) and  single quotes ( ' ) generate SQL error while saving.

Re: Multiline text box

tcoton wrote:

Thanks, this does the trick, however, speach marks  ( " ) and  single quotes ( ' ) generate SQL error while saving.

Thank you, fixed, please download the example again.

Dmitry.

Re: Multiline text box

Very good!

And what about a scroll bar? big_smile

Re: Multiline text box

Form1.Memo1.ScrollBars := ssNone; // The component has no scroll bars. (default)
Form1.Memo1.ScrollBars := ssHorizontal; // The component has a single scroll bar on the bottom edge.
Form1.Memo1.ScrollBars := ssVertical; // The component has a single scroll bar on the right edge.
Form1.Memo1.ScrollBars := ssBoth; // The component has a scroll bar on both the bottom and right edges.
Dmitry.

Re: Multiline text box

That was too easy for you smile

Re: Multiline text box

Everything works perfectly, thanks a lot Dmitry for your fast replies.

I just changed a detail, I use the OnShow event so the memo is automatically displayed and I tick the Read Only property before compiling so the users cannot edit my memo smile

This makes my life way easier to log / display the dev history.

16 (edited by tcoton 2015-01-27 13:24:53)

Re: Multiline text box

Actually, I still have an issue with scroll bar, there is some kind of scroll bar displayed but I cannot use it!

On the attached screenshot, there is some text which cannot be displayed at the top.

Post's attachments

Attachment icon memo-pbMvdb.jpg 155.77 kb, 354 downloads since 2015-01-27 

Re: Multiline text box

tcoton
Can you send me project for test?
support@drive-software.com

Dmitry.

Re: Multiline text box

It was my fault actually, thanks Dmitriy for your support, I just missed some lines when I copied-paste the original text from dev to prod in the memo... shame on me !

19 (edited by tcoton 2015-10-12 15:01:09)

Re: Multiline text box

Any news for a true multiline textbox component?

I need to support multiline entries in my project and I struggle to get it working properly. When designing I can draw a very nice big textbox which reduces automatically to 1 line when starting the application.

I tried to use memo instead but it retains latest entry every time I display the edition form without closing the application on same record. Is there a way to at least clear the memo component when closing the form?

http://myvisualdatabase.com/forum/misc.php?action=pun_attachment&item=1396

Post's attachments

Attachment icon multiline_textbox.png 22.71 kb, 330 downloads since 2015-10-12 

Re: Multiline text box

tcoton

I tried to use memo instead but it retains latest entry every time I display the edition form without closing the application on same record. Is there a way to at least clear the memo component when closing the form?

The component should be cleared automatically.
Please send me your project to support@drive-software.com
I'll test it

Dmitry.

Re: Multiline text box

The component is not cleared until I restart the application, you could easily try it yourself smile

To clear it, I must exit my application and restart it? I am using 2.03 alpha.

Re: Multiline text box

tcoton wrote:

The component is not cleared until I restart the application, you could easily try it yourself smile

To clear it, I must exit my application and restart it? I am using 2.03 alpha.

Checked, all works fine, please download the example:

Post's attachments

Attachment icon Employees.zip 4.8 kb, 514 downloads since 2015-10-13 

Dmitry.

Re: Multiline text box

Ok I see, we do not use it the same way smile

I actually use the memo component to be able to write a multiline comment with clear view on what is being written, then I click on "Save Maintenance", it records all entries in a table "Maintenances" using scripts shown below. When opening back the form for the same switch (show record) last entry remains.

// Save maintenance into separate table
procedure ADD_switch_Button1_OnClick (Sender: string; var Cancel: boolean);
begin

   SQLExecute ('INSERT INTO maintenances (Hostname,Description,DateMaint,IMAC,MAC_ADDRESS) VALUES ('+ ADD_switch.hostname_add.sqlValue+','+ADD_switch.Descript1.sqlValue+','+ADD_switch.DateMaint.sqlDate+', '+ADD_switch.IMAC.sqlValue+','+ADD_switch.mac_add.sqlValue+' )');

    ADD_switch.Close;

end;


// Display maintenances related to current Switch

procedure ADD_switch_OnShow (Sender: string; Action: string);
var
    sSW_ID: string;
begin
    sSW_ID := ADD_switch.mac_add.sqlValue; // get current MAC Address

    ADD_switch.MaintHistory.dbSQL:='SELECT Hostname, MAC_ADDRESS, Description, strftime("%d.%m.%Y" ,Datemaint), IMAC FROM Maintenances where MAC ='+sSW_ID+;
    ADD_switch.MaintHistory.dbListFieldsNames :='Hostname,Details Maint,Date Maint, IMAC';
    ADD_switch.MaintHistory.dbSQLExecute;
end;

Re: Multiline text box

try this:

// Save maintenance into separate table
procedure ADD_switch_Button1_OnClick (Sender: string; var Cancel: boolean);
begin

   SQLExecute ('INSERT INTO maintenances (Hostname,Description,DateMaint,IMAC,MAC_ADDRESS) VALUES ('+ ADD_switch.hostname_add.sqlValue+','+ADD_switch.Descript1.sqlValue+','+ADD_switch.DateMaint.sqlDate+', '+ADD_switch.IMAC.sqlValue+','+ADD_switch.mac_add.sqlValue+' )');

    ADD_switch.Descript1.Clear;
    ADD_switch.Close;

end;
Dmitry.

Re: Multiline text box

It works perfectly thank you, I even have the "bubble text" when hovering the mouse on the result grid when the text is too long smile

This is the magic line

ADD_switch.Descript1.Clear;