Click here to Skip to main content
15,906,097 members
Home / Discussions / C#
   

C#

 
GeneralRe: MDI app and hosted controls Pin
Dave Kreskowiak29-Oct-04 5:05
mveDave Kreskowiak29-Oct-04 5:05 
GeneralGetting properties of a MS Word file Pin
Weckmann29-Oct-04 1:09
Weckmann29-Oct-04 1:09 
GeneralSize assignment to a control Pin
eDip29-Oct-04 0:07
eDip29-Oct-04 0:07 
GeneralRe: Size assignment to a control Pin
Stanciu Vlad29-Oct-04 4:49
Stanciu Vlad29-Oct-04 4:49 
GeneralRe: Size assignment to a control Pin
Dave Kreskowiak29-Oct-04 4:54
mveDave Kreskowiak29-Oct-04 4:54 
GeneralRe: Size assignment to a control Pin
Ketty Avashia29-Oct-04 9:45
Ketty Avashia29-Oct-04 9:45 
GeneralPrint RichTextBox Docs... Pin
Zamolxes28-Oct-04 23:56
Zamolxes28-Oct-04 23:56 
GeneralRe: Print RichTextBox Docs... Pin
sreejith ss nair29-Oct-04 4:44
sreejith ss nair29-Oct-04 4:44 
I think i already post answer for the same question.
Anyhow don't upset.;)

<br />
try<br />
{<br />
PrintDia=new PrintDialog();<br />
PrintDia.Document=printDocument1;<br />
string content=this.RitchEditor.Text;<br />
StrReader=new StringReader(content);<br />
if(PrintDia.ShowDialog()==DialogResult.OK)<br />
{<br />
this.printDocument1.Print();<br />
}<br />
}<br />
catch(Exception Ex)<br />
{<br />
MessageBox.Show(Ex.Message.ToString());<br />
}<br />


This much is very easy one who know how to print the content. Next is importent.

<br />
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)<br />
		{<br />
			try<br />
			{<br />
			float Lines_Per_Page = 0;<br />
			float Y_Position     = 0; <br />
			int Count            = 0;<br />
			float Left_Margin    = e.MarginBounds.Left;<br />
			float Top_Margin   = e.MarginBounds.Top;<br />
<br />
			string Line = null;<br />
			Font fnt    = Editor.Font;<br />
			SolidBrush Solid = new SolidBrush(Color.Black);<br />
<br />
			Lines_Per_Page=e.MarginBounds.Height/Font.GetHeight(e.Graphics);<br />
<br />
            while(Count < Lines_Per_Page &&  ((Line=StrReader.ReadLine())!=null ))<br />
	<br />
			{<br />
<br />
				// calculate the next line position based on<br />
				// the height of the font according to the printing device <br />
				Y_Position =Top_Margin + (Count * fnt.GetHeight(e.Graphics));<br />
<br />
				// draw the next line in the rich edit control <br />
<br />
				e.Graphics.DrawString(Line ,fnt ,Solid ,Left_Margin ,Y_Position ,new StringFormat());<br />
				<br />
				Count++;<br />
			}<br />
<br />
           if(Line !=null)<br />
			   e.HasMorePages=true;<br />
			else<br />
			   e.HasMorePages=false;<br />
		}<br />
		catch(Exception Ex)<br />
	{<br />
		MessageBox.Show(Ex.Message.ToString());<br />
	}<br />
<br />
   <br />
		}


Sreejith Nair
[ My Articles ]
GeneralRe: Print RichTextBox Docs... Pin
Dave Kreskowiak29-Oct-04 4:49
mveDave Kreskowiak29-Oct-04 4:49 
Generalpixel matrix and neural network Pin
Phu Nguyen Si28-Oct-04 22:01
Phu Nguyen Si28-Oct-04 22:01 
GeneralInteresting error Pin
StephenMcAllister28-Oct-04 21:28
StephenMcAllister28-Oct-04 21:28 
GeneralRe: Interesting error Pin
Stanciu Vlad29-Oct-04 4:46
Stanciu Vlad29-Oct-04 4:46 
GeneralRe: Deployment Project Pin
Dave Kreskowiak29-Oct-04 4:40
mveDave Kreskowiak29-Oct-04 4:40 
QuestionHow to do this in C#? Pin
momer28-Oct-04 20:58
momer28-Oct-04 20:58 
AnswerRe: How to do this in C#? Pin
Daniel Turini28-Oct-04 21:31
Daniel Turini28-Oct-04 21:31 
QuestionHow to suspend a process in c# Pin
mendi_198328-Oct-04 20:21
mendi_198328-Oct-04 20:21 
AnswerRe: How to suspend a process in c# Pin
Dave Kreskowiak29-Oct-04 4:37
mveDave Kreskowiak29-Oct-04 4:37 
AnswerRe: How to suspend a process in c# Pin
Alvaro Mendez29-Oct-04 5:20
Alvaro Mendez29-Oct-04 5:20 
Generaladdress of an object reference variable in C# Pin
Diana Fernandez28-Oct-04 20:16
Diana Fernandez28-Oct-04 20:16 
Generalexception generated from graphics.FromImage Pin
cchere28-Oct-04 18:43
cchere28-Oct-04 18:43 
GeneralRe: exception generated from graphics.FromImage Pin
Maqsood Ahmed28-Oct-04 23:26
Maqsood Ahmed28-Oct-04 23:26 
GeneralRe: exception generated from graphics.FromImage Pin
cchere29-Oct-04 4:19
cchere29-Oct-04 4:19 
Questionhow to make a bmp image editor with grid Pin
tom_dx28-Oct-04 16:42
tom_dx28-Oct-04 16:42 
Generalp/Invoke using sendmessage in C# Pin
ting66828-Oct-04 16:32
ting66828-Oct-04 16:32 
GeneralRe: p/Invoke using sendmessage in C# Pin
Heath Stewart30-Oct-04 2:31
protectorHeath Stewart30-Oct-04 2:31 

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.