Table with one or two columns
-
- Posts: 16
- Joined: Wed Aug 26, 2009 7:58 pm
Table with one or two columns
Hi,
I'm a new programmer with RichView and I want to do things right.
I need to provide to user a RichView that display information in one or two columns. To provide these two options I created two buttons that display "One column" or "Two column" in the Caption. What is important is that only one option can be choosen.
If they select one column, I would like that the RichView contains a table with one column and if they select two columns, the RichView would create a table containg two columns.
I've been able to create a table with one or two columns.
My problem is that if the user has already inserted information in the two columns table and they select the one column table I don't know how to copy all that was inserted inside the two columns styles included, erase all in the RichView, create the new table with one column and put inside the new table the content copy earlier.
Do you have an example on how to do this?
Best regards,
Helene
I'm a new programmer with RichView and I want to do things right.
I need to provide to user a RichView that display information in one or two columns. To provide these two options I created two buttons that display "One column" or "Two column" in the Caption. What is important is that only one option can be choosen.
If they select one column, I would like that the RichView contains a table with one column and if they select two columns, the RichView would create a table containg two columns.
I've been able to create a table with one or two columns.
My problem is that if the user has already inserted information in the two columns table and they select the one column table I don't know how to copy all that was inserted inside the two columns styles included, erase all in the RichView, create the new table with one column and put inside the new table the content copy earlier.
Do you have an example on how to do this?
Best regards,
Helene
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 16
- Joined: Wed Aug 26, 2009 7:58 pm
The content should go like this:
From one to two columns : content remains inside the first column.
From two to one column: content from column one + blank line + content from column 2 goes into column one and column two disapear.
All the style already apply to text as bold, italic, underline must be kept.
When in two columns the bestwidth for each column must be equal to 345.
Thanks for helping me.
From one to two columns : content remains inside the first column.
From two to one column: content from column one + blank line + content from column 2 goes into column one and column two disapear.
All the style already apply to text as bold, italic, underline must be kept.
When in two columns the bestwidth for each column must be equal to 345.
Thanks for helping me.
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 16
- Joined: Wed Aug 26, 2009 7:58 pm
Almost working
Hello,
This is working pretty well.
I just forgot to mentioned that only one table was possible in the DBRichViewEdit. I really need the user to not be able to add more than one table with one or two columns in the DBRichViewEdit.
Thanks again for your help!
This is very cool!
This is working pretty well.
I just forgot to mentioned that only one table was possible in the DBRichViewEdit. I really need the user to not be able to add more than one table with one or two columns in the DBRichViewEdit.
Thanks again for your help!
This is very cool!
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Place the table in paragraph style having rvpaoNoWrap, rvpaoReadOnly, rvpaoStyleProtect in Options.
If you use TDBRichViewEdit, place this code in OnNewDocument event.
If you use TDBRichViewEdit, place this code in OnNewDocument event.
Code: Select all
var table: TRVTableItemInfo;
DBRichViewEdit1.ParaStyles.Clear;
DBRichViewEdit1.ParaStyles.Add; // normal paragraph style
with DBRichViewEdit1.ParaStyles.Add do // protected paragraph style
Options := [rvpaoNoWrap, rvpaoReadOnly, rvpaoStyleProtect];
table := TRVTableItemInfo.CreateEx(1, 1, DBRichViewEdit1.RVData);
table.ParaNo := 1; // protected style index
DBRichViewEdit1.Clear;
DBRichViewEdit1.AddItem('', table);
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
The commands for changing column count in the example above were not implemented as an editing operation. So, if you use TDBRichViewEdit, you need to add code to make it work properly (see http://www.trichview.com/help/idh_examp ... edit1.html )
The same for To2Columns.
Code: Select all
if DBRichViewEdit1.CanChange then begin
To1Column;
DBRichViewEdit1.Change;
end;
-
- Posts: 16
- Joined: Wed Aug 26, 2009 7:58 pm
It's almost working
Hi,
I would like to thank you for taking the time to provide me an example.
It help me implement what I needed for my client.
To make sure that the client could not insert anything else outside of the table I inserted in the OnChanging event this
If DBRichViewContenu.TopLevelEditor=DBRichViewContenu then
begin
CanEdit := False;
end;
If I understood well in another forum issue, this should mean that I am at the root of DBRichViewContenu and tells me that I am not in a table cell.
Can you tell me if I done it the right way?
The part that is not working at this time is the part for the OnNewDocument.
I'm working with a DBRichView and I encountered an error with ParaStyles.
I'm still trying to make it work. Just missing time right now.
Thanks for your kind help.
I would like to thank you for taking the time to provide me an example.
It help me implement what I needed for my client.
To make sure that the client could not insert anything else outside of the table I inserted in the OnChanging event this
If DBRichViewContenu.TopLevelEditor=DBRichViewContenu then
begin
CanEdit := False;
end;
If I understood well in another forum issue, this should mean that I am at the root of DBRichViewContenu and tells me that I am not in a table cell.
Can you tell me if I done it the right way?
The part that is not working at this time is the part for the OnNewDocument.
I'm working with a DBRichView and I encountered an error with ParaStyles.
I'm still trying to make it work. Just missing time right now.
Thanks for your kind help.
-
- Posts: 16
- Joined: Wed Aug 26, 2009 7:58 pm
Oups! Little problem
Hello,
When I insert some bold, underline or italic style in column 2 and than try to switch to one column all the content of column number 2 is not added properly to column 1. All the content following the first style inserted (for example bold with italic) in column 2 dissapear. If I save I get an error when I try to reload.
I'm working with a DBRichView.
Do you know why and what I should do? Is it in the copying process?
It's funny because we copy without styles.
Thanks for your help.
When I insert some bold, underline or italic style in column 2 and than try to switch to one column all the content of column number 2 is not added properly to column 1. All the content following the first style inserted (for example bold with italic) in column 2 dissapear. If I save I get an error when I try to reload.
I'm working with a DBRichView.
Do you know why and what I should do? Is it in the copying process?
It's funny because we copy without styles.
Thanks for your help.
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 16
- Joined: Wed Aug 26, 2009 7:58 pm
Drag and drop problem after switching to two columns
Hello,
This is a new issue that I've been informed while using the application.
Just after switching the content of the richviewedit to two columns, if I select some text in the first column and want to drag it to the second column I get an error that force me to close the application and restart it.
But if I make a simple click in the second column and then select text from my first column and drag it, there is no error.
Should I insert some code prior to the drag and drop. Should I focus the second column just after I created the second column. If so what coding should I add to make this work?
Thanks for your help!
This is a new issue that I've been informed while using the application.
Just after switching the content of the richviewedit to two columns, if I select some text in the first column and want to drag it to the second column I get an error that force me to close the application and restart it.
But if I make a simple click in the second column and then select text from my first column and drag it, there is no error.
Should I insert some code prior to the drag and drop. Should I focus the second column just after I created the second column. If so what coding should I add to make this work?
Thanks for your help!
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I cannot reproduce this error when using the demo http://www.trichview.com/support/files/ ... olumns.zip and the latest version of TRichView.
Can you create a simple project reproducing it?
Can you create a simple project reproducing it?
-
- Posts: 16
- Joined: Wed Aug 26, 2009 7:58 pm
Follow up on problem encounter
Hi,
I have found the problem but don't understand why it is giving an error. Maybe it is a bug. Only you will be able to tell me.
By clicking the 2 columns button with the code that you provided me, it create automatically the second columns.
I found out that just after inserting the second column
table.InsertCols(1,1,-1,False);
i've added this line of code
table.Cells[0,1].Clear;
When this line is active, the program generate an error when droping text in the second column. I've also tried it in the demo. When the line is comment no error is given when dragging and dropping.
When I'm looking at the code I understand that as I just created the second column I shouldn't have to clear it but as I've seen other example of richview table creation and it was called, I thought I should execute it as a default in my program.
Can you tell me why does this line provide an error and what I should do if I would want to keep this line active?
Best regards,
I have found the problem but don't understand why it is giving an error. Maybe it is a bug. Only you will be able to tell me.
By clicking the 2 columns button with the code that you provided me, it create automatically the second columns.
I found out that just after inserting the second column
table.InsertCols(1,1,-1,False);
i've added this line of code
table.Cells[0,1].Clear;
When this line is active, the program generate an error when droping text in the second column. I've also tried it in the demo. When the line is comment no error is given when dragging and dropping.
When I'm looking at the code I understand that as I just created the second column I shouldn't have to clear it but as I've seen other example of richview table creation and it was called, I thought I should execute it as a default in my program.
Can you tell me why does this line provide an error and what I should do if I would want to keep this line active?
Best regards,
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I cannot reproduce this error after adding this line. May be you made other changes in the code?
When you add a new column, its cells contains one empty text item - it is necessary both for calculating row heights, and for the caret positioning.
When you call Cell.Clear, you remove this text item. But when you call Format, it fixes this problem by adding this text item again. So calling Cell.Clear should do nothing.
When you add a new column, its cells contains one empty text item - it is necessary both for calculating row heights, and for the caret positioning.
When you call Cell.Clear, you remove this text item. But when you call Format, it fixes this problem by adding this text item again. So calling Cell.Clear should do nothing.