Click here to Skip to main content
15,902,114 members
Home / Discussions / C#
   

C#

 
QuestionInterop: Anyone know how to save an Excel workbook without the "Do you want to save" popup? Pin
Alaric_16-Nov-11 4:01
professionalAlaric_16-Nov-11 4:01 
AnswerRe: Interop: Anyone know how to save an Excel workbook without the "Do you want to save" popup? Pin
Not Active16-Nov-11 4:07
mentorNot Active16-Nov-11 4:07 
GeneralRe: Interop: Anyone know how to save an Excel workbook without the "Do you want to save" popup? Pin
Alaric_16-Nov-11 4:09
professionalAlaric_16-Nov-11 4:09 
AnswerRe: Interop: Anyone know how to save an Excel workbook without the "Do you want to save" popup? Pin
Alaric_16-Nov-11 4:08
professionalAlaric_16-Nov-11 4:08 
QuestionZoom window box (attached to mouse pointer) Pin
Blubbo16-Nov-11 3:39
Blubbo16-Nov-11 3:39 
QuestionWinForms - Detect End of RichTextBox Pin
Matt U.16-Nov-11 2:40
Matt U.16-Nov-11 2:40 
AnswerRe: WinForms - Detect End of RichTextBox Pin
V.16-Nov-11 3:56
professionalV.16-Nov-11 3:56 
GeneralRe: WinForms - Detect End of RichTextBox Pin
Matt U.16-Nov-11 4:48
Matt U.16-Nov-11 4:48 
Wow. I guess I should not ask questions when I am terribly sleep deprived. Anyhow, I should clarify the question now.

I have a panel which contains "pages". Each page is a RichTextBox control which I create at a specific size. I set the size at 8.5 * DpiX by 11 * DpiY, which, from what I read, is like 8.5" x 11" on the screen. This size is fixed, meaning the size of the RTB will never change.

The functionality I wish to achieve is similar to that of Microsoft Word, in which the user types on a page (RTB control). And once the text reaches the bottom of the RTB's bounds, I would like to move the "offending" text (the text which does not fit in that particular RTB) to a new page/RTB, which is placed below the original page. I have already implemented inserting pages and such, by adding a new RTB control to the container panel. This works as expected.

I have done some more digging and I found the RTB event called "ContentsResized". MSDN says "Occurs when contents within the control are resized." After playing with this event I have discovered that I can detect when the last line goes beyond the RTB's height. Here is what I have:

C#
MuRichTextBox page = (MuRichTextBox)sender;
int topMargin = (int)(page.TopTextMargin * DpiY);
int bottomMargin = (int)(page.BottomTextMargin * DpiY);

if (page.Lines.Length > 0 && e.NewRectangle.Height > (page.Height - (topMargin + bottomMargin)))
{
    // Move the last line to a new page
    if (page == this._pages[this._pages.Count - 1])    // Add a new page
        this.InsertPage();
}


DpiY is retrieved from:

C#
Graphics g = page.CreateGraphics();
float DpiY = g.DpiY;


When I use this a new page is inserted. But I am not sure how to move the "offending" line from the first page to the newly inserted page. Is that more clear?
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.

GeneralRe: WinForms - Detect End of RichTextBox Pin
V.25-Nov-11 3:23
professionalV.25-Nov-11 3:23 
AnswerRe: WinForms - Detect End of RichTextBox Pin
BobJanova16-Nov-11 6:07
BobJanova16-Nov-11 6:07 
GeneralRe: WinForms - Detect End of RichTextBox Pin
Matt U.16-Nov-11 8:20
Matt U.16-Nov-11 8:20 
GeneralRe: WinForms - Detect End of RichTextBox Pin
Pete O'Hanlon16-Nov-11 8:45
mvePete O'Hanlon16-Nov-11 8:45 
GeneralRe: WinForms - Detect End of RichTextBox Pin
Matt U.16-Nov-11 8:50
Matt U.16-Nov-11 8:50 
GeneralRe: WinForms - Detect End of RichTextBox Pin
BobJanova16-Nov-11 23:16
BobJanova16-Nov-11 23:16 
AnswerRe: WinForms - Detect End of RichTextBox Pin
BillWoodruff16-Nov-11 14:41
professionalBillWoodruff16-Nov-11 14:41 
QuestionBug in ShowWindow in Windows 7 Pin
Axonn Echysttas16-Nov-11 2:08
Axonn Echysttas16-Nov-11 2:08 
Questionproblem: popup image onclick gridview image using model popup and web service Pin
Rohit Sharma70616-Nov-11 1:38
Rohit Sharma70616-Nov-11 1:38 
QuestionUpdating the password handling Pin
Bernhard Hiller15-Nov-11 20:32
Bernhard Hiller15-Nov-11 20:32 
AnswerRe: Updating the password handling PinPopular
Peter_in_278015-Nov-11 20:45
professionalPeter_in_278015-Nov-11 20:45 
GeneralRe: Updating the password handling Pin
OriginalGriff16-Nov-11 0:13
mveOriginalGriff16-Nov-11 0:13 
GeneralRe: Updating the password handling Pin
Reiss16-Nov-11 2:57
professionalReiss16-Nov-11 2:57 
GeneralRe: Updating the password handling Pin
Peter_in_278016-Nov-11 9:53
professionalPeter_in_278016-Nov-11 9:53 
GeneralRe: Updating the password handling Pin
Bernhard Hiller16-Nov-11 21:45
Bernhard Hiller16-Nov-11 21:45 
AnswerRe: Updating the password handling Pin
BobJanova16-Nov-11 3:04
BobJanova16-Nov-11 3:04 
AnswerRe: Updating the password handling Pin
Luc Pattyn16-Nov-11 4:03
sitebuilderLuc Pattyn16-Nov-11 4:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.