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.
My Visual Database → General → 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.
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.
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.
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
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.
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
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?
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.
Sounds good, thanks Dmitry.
How would do to save and load the text from database instead of an external text?
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:
Thanks, this does the trick, however, speach marks ( " ) and single quotes ( ' ) generate SQL error while saving.
Thanks, this does the trick, however, speach marks ( " ) and single quotes ( ' ) generate SQL error while saving.
Thank you, fixed, please download the example again.
Very good!
And what about a scroll bar?
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.
That was too easy for you
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
This makes my life way easier to log / display the dev history.
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.
tcoton
Can you send me project for test?
support@drive-software.com
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 !
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?
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
The component is not cleared until I restart the application, you could easily try it yourself
To clear it, I must exit my application and restart it? I am using 2.03 alpha.
The component is not cleared until I restart the application, you could easily try it yourself
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:
Ok I see, we do not use it the same way
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;
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;
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
This is the magic line
ADD_switch.Descript1.Clear;
My Visual Database → General → Multiline text box
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi