Page 1 of 1
Templates similar in MS Word
Posted: Wed Jul 28, 2010 3:12 am
by snike555
How to make a TRichEdit text is not editable except for special fields (smth like MS Word templates) and jump between editable fields with Tab or Enter. Is it possible?
Posted: Wed Jul 28, 2010 3:15 am
by snike555
TRichEdit = TDBRichViewEdit
Posted: Wed Jul 28, 2010 11:39 am
by Sergey Tkachenko
One of possible solutions: insert controls (like TEdit). You will be able to navigate with tabs between them.
When you need a final result (for example, for printing), you can replace controls to text, see
http://www.trichview.com/forums/viewtopic.php?t=1131
See also
http://www.trichview.com/help/idh_examp ... edit2.html for using TEdits in TDBRichViewEdit.
Posted: Thu Jul 29, 2010 7:40 am
by snike555
Thank you.
My update:
Code: Select all
procedure TForm1.EditChange(Sender: TObject);
var
tw : Integer;
begin
if Sender is TEdit then
begin
tw := Canvas.TextWidth(TEdit(Sender).Text);
if tw < 50 then
tw := 50;
TEdit(Sender).Width := tw + 15;
end;
if DBRVE.CanChange then
begin
DBRVE.Change;
DBRVE.Format;
end
else
Beep;
end;
1) How to remove control (TEdit) from TDBRichViewEdit?
2) How TabOrder where add new TEdit?
Posted: Thu Jul 29, 2010 8:36 am
by Sergey Tkachenko
How a control must be removed?
--
Unfortunately, it's not simple to control tab order in TRichViewEdit/TDBRichViewEdit.
However, if you load this document in TRichView/TDBRichView, Tab and Shift+Tab will work properly (navigating between controls and hyperlinks). Tab will move the focus to the next control in the document, ignoring TabOrder property.
Posted: Thu Jul 29, 2010 9:17 am
by snike555
Sergey Tkachenko wrote:How a control must be removed?
Yes, how?
[quote="Sergey Tkachenko"
Unfortunately, it's not simple to control tab order in TRichViewEdit/TDBRichViewEdit.
However, if you load this document in TRichView/TDBRichView, Tab and Shift+Tab will work properly (navigating between controls and hyperlinks). Tab will move the focus to the next control in the document, ignoring TabOrder property.[/quote]
It's true, but how make tabOrder where add new TEdit?
Posted: Thu Jul 29, 2010 9:42 am
by Sergey Tkachenko
I mean, do you want to delete the control?
Do you want to delete the focused control as an editing operation (undoable) or do you want something different?
For example, one of possibilities to delete all controls and replace them to their text is shown in
http://www.trichview.com/forums/viewtopic.php?t=1131
You can assign TabOrder property of new TEdit inserted in document. Or call a code that enumerates all controls in the document and assign their TabOrders.
It will work ok in the main document, but not in tables (one of the problems - in tables of TRichViewEdit, TAB moves the caret to the next cell).
As I can guess, you need 3 modes:
1) editing templates, inserting and deleting controls and text between them; in this mode, TABs are not important, because any text is editable; just edit documents in TDBRichViewEdit
2) filling a template with data; just load this document in TRichView or TDBRichView. TAB will move to the next control in the document, so you do not need to worry about tab order. The only problem: you will not be able to change control widths according to text size.
3) printing; you can print either the document as it is, or after replacing all controls to text, as it shown in
http://www.trichview.com/forums/viewtopic.php?t=1131
Posted: Thu Jul 29, 2010 9:51 am
by snike555
I want to delete the focused control.
Posted: Sat Jul 31, 2010 5:13 pm
by Sergey Tkachenko
Code: Select all
if RichViewEdit1.SelectControl(ActiveControl) then begin
RichViewEdit1.DeleteSelection;
RichViewEdit1.SetFocus;
end;
It is assumed that this code is called in a form's method, because it uses form's ActiveControl property.
Posted: Mon Aug 02, 2010 5:25 am
by snike555
Thank you, it's ok!
Next question on this subject:
Now:
I want:
Posted: Mon Aug 02, 2010 10:14 am
by snike555
And next problem:
Code: Select all
if not (ActiveControl is TDBRichViewEdit) then Exit;
CB := TComboBox.Create(nil);
CB.Width := 80;
CB.PopupMenu := PMCB;
CB.OnChange := EditChange;
DBRVE.InsertControl('', CB, rvvaBaseline);
- It's work!
But, this don't work:
Code: Select all
if not (ActiveControl is TDBRichViewEdit) then Exit;
CB := TDBComboBoxEh.Create(nil);
CB.Width := 80;
CB.PopupMenu := PMCB;
CB.OnChange := EditChange;
CB.DropBox.Sizible := True;
DBRVE.InsertControl('', CB, rvvaBaseline);
After save data in TDBRichViewEdit component TDBComboBoxEh not showed.
Posted: Mon Aug 02, 2010 3:58 pm
by Sergey Tkachenko
As for vertical alignment, use rvvaAbsMiddle instead of rvvaBaseline when inserting a control.
What's TDBComboBoxEh?
Posted: Tue Aug 03, 2010 3:24 am
by snike555
TDBComboBoxEh from
http://ehlib.com/
Replace controls to text with TComboBox don't work.
I use TDBRichViewEdit v. 12.2.3. and Delphi 2010 upd 4/5
Posted: Tue Aug 03, 2010 7:23 am
by Sergey Tkachenko
I'll try to test TDBComboBoxEd later.
Do you mean that the demo
http://www.trichview.com/forums/viewtopic.php?t=1131 does not work with TComboBox? But how is it possible? This demo has TComboBox in a sample document.
This demo has GetControlText function returning text for the given control. In this demo, it supports TComboBox, TEdit and TRadioGroup, but you can easily modify it for other control types.