Templates similar in MS Word
Templates similar in MS Word
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?
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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.
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.
Thank you.
My update:
1) How to remove control (TEdit) from TDBRichViewEdit?
2) How TabOrder where add new TEdit?
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;
2) How TabOrder where add new TEdit?
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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.
--
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.
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?
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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
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
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Code: Select all
if RichViewEdit1.SelectControl(ActiveControl) then begin
RichViewEdit1.DeleteSelection;
RichViewEdit1.SetFocus;
end;
And next problem:
- It's work!
But, this don't work:
After save data in TDBRichViewEdit component TDBComboBoxEh not showed.
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.
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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
Replace controls to text with TComboBox don't work.
I use TDBRichViewEdit v. 12.2.3. and Delphi 2010 upd 4/5
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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.
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.