Special Handling for Tables
Special Handling for Tables
When the first item in a dbrichview document is a table, I want to automatically position the cursor within the first cell at the first character. If the first item is not a table, I want the default behavior.
How can I accomplish this in my formcreate method?
How can I accomplish this in my formcreate method?
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
You can use Table.AfterScroll event:
Code: Select all
procedure TForm1.Table1AfterScroll(DataSet: TDataSet);
begin
if (DBRichViewEdit1.ItemCount>0) and (DBRichViewEdit1.GetItemStyle(0)=rvsTable) then
TRVTableItemInfo(DBRichViewEdit1.GetItem(0)).EditCell(0,0);
end;
One more issue I'm encountering.
When I have an empty document, the cursor sometimes (unpredictable) does not place itself within the margins I've created with the rulers (1 inch left and right, and 1 inch top and bottom). Instead the cursor shows up in the upper left corner.
When I start typing, the cursor jumps to the correct position, but when I import a document, if the first item is a bullet, the bullet is to the left of my left margin, which I must then reset manually.
Any idea why this is happening?
Thanks in advance.
When I have an empty document, the cursor sometimes (unpredictable) does not place itself within the margins I've created with the rulers (1 inch left and right, and 1 inch top and bottom). Instead the cursor shows up in the upper left corner.
When I start typing, the cursor jumps to the correct position, but when I import a document, if the first item is a bullet, the bullet is to the left of my left margin, which I must then reset manually.
Any idea why this is happening?
Thanks in advance.
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I'm still getting this behavior.
Here is the code:
if (DBRichViewEdit1.ItemCount > 0) and (DBRichViewEdit1.GetItemStyle(0) = rvsTable) then
TRVTableItemInfo(DBRichViewEdit1.GetItem(0)).EditCell(0,0)
else
DBRichViewEdit1.SetSelectionBounds (0,DBRichViewEdit1.GetOffsBeforeItem(0), 0, DBRichViewEdit1.GetOffsBeforeItem(0));
rvRuler1.UpdateRulerMargins;
rvRuler2.UpdateRulerMargins;
(if the first item in document is a table, move to the 1st cell, 1st character, else move to the beginning of the first paragraph, then as you instructed, add the UpdateRulerMargins.
Here is the code:
if (DBRichViewEdit1.ItemCount > 0) and (DBRichViewEdit1.GetItemStyle(0) = rvsTable) then
TRVTableItemInfo(DBRichViewEdit1.GetItem(0)).EditCell(0,0)
else
DBRichViewEdit1.SetSelectionBounds (0,DBRichViewEdit1.GetOffsBeforeItem(0), 0, DBRichViewEdit1.GetOffsBeforeItem(0));
rvRuler1.UpdateRulerMargins;
rvRuler2.UpdateRulerMargins;
(if the first item in document is a table, move to the 1st cell, 1st character, else move to the beginning of the first paragraph, then as you instructed, add the UpdateRulerMargins.
I've been testing the application a bit more, and find that even when the document has text, in some instances the cursor positions itself upper left corner not within the margins.
Again, this is random, I can open up a document with the cursor in the correct position many times, then the next time, it won't be.
Even with the cursor in the incorrect position, typing snaps the cursor to the correct position.
Again, this is random, I can open up a document with the cursor in the correct position many times, then the next time, it won't be.
Even with the cursor in the incorrect position, typing snaps the cursor to the correct position.
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Another hint...
Just figured out the pattern on when the cursor shows up in the wrong position.
My application is an MDI application. Each time my MDI frame creates a new form, the new one shows up offset down and to the right (as defined by windows). After a few iterations of creating forms (with the DBrichviewedit on it), the incorrectly placed cursor starts to occur. When the cycle is complete, and the new form once again starts at the upper left of my MDI frame, the cursor once again obeys the margins.
Just figured out the pattern on when the cursor shows up in the wrong position.
My application is an MDI application. Each time my MDI frame creates a new form, the new one shows up offset down and to the right (as defined by windows). After a few iterations of creating forms (with the DBrichviewedit on it), the incorrectly placed cursor starts to occur. When the cycle is complete, and the new form once again starts at the upper left of my MDI frame, the cursor once again obeys the margins.
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: