Click here to Skip to main content
15,921,959 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to implement a registration key with the following requirement? Pin
Christian Graus16-Aug-04 17:10
protectorChristian Graus16-Aug-04 17:10 
GeneralMS Access Password Pin
Johnnypvan16-Aug-04 13:43
Johnnypvan16-Aug-04 13:43 
GeneralRe: MS Access Password Pin
S Sansanwal16-Aug-04 14:57
S Sansanwal16-Aug-04 14:57 
GeneralRe: MS Access Password Pin
Johnnypvan17-Aug-04 2:10
Johnnypvan17-Aug-04 2:10 
GeneralNtier app Pin
StephenMcAllister16-Aug-04 11:42
StephenMcAllister16-Aug-04 11:42 
Generaldatareader to datagrid Pin
kings_116-Aug-04 11:41
kings_116-Aug-04 11:41 
GeneralRe: datareader to datagrid Pin
S Sansanwal16-Aug-04 15:07
S Sansanwal16-Aug-04 15:07 
GeneralPrint blank page Pin
Titan516-Aug-04 10:34
Titan516-Aug-04 10:34 
The print preview showed two pages with text but after clicking Print on the print preview dialog window, only one blank page printed out from the printer. Any clue?

Two methods below:
private void btnPrintPreview_Click(object sender, System.EventArgs e)
{
try
{
streamToPrint = new StreamReader("C:\\Test1.txt");
try
{
printFont = new Font("Arial", 10);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
PrintPreviewDialog aPPDialog = new PrintPreviewDialog();
aPPDialog.Document = pd;
aPPDialog.ShowDialog(); //this shows up the print preview dialog window!
}
finally
{
//streamToPrint.Close();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
return;
}


private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
float linesPerPage = 0;
float yPos = 0;
int count = 0;
float leftMargin = ev.MarginBounds.Left;
float topMargin = ev.MarginBounds.Top;
string line = null;
linesPerPage = 75;
while(count < linesPerPage &&
((line=streamToPrint.ReadLine()) != null))
{
yPos = topMargin + (count * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString(line, printFont, Brushes.Black,
leftMargin, yPos, new StringFormat());
count++;
}
if(line != null)
ev.HasMorePages = true;
else
ev.HasMorePages = false;
}
Any idea what went wrong or what was missing in my code? Thanks.Confused | :confused:
GeneralVS 2005 beta - warnings galore Pin
Judah Gabriel Himango16-Aug-04 9:45
sponsorJudah Gabriel Himango16-Aug-04 9:45 
GeneralRe: VS 2005 beta - warnings galore Pin
Nick Parker16-Aug-04 10:13
protectorNick Parker16-Aug-04 10:13 
GeneralRe: VS 2005 beta - warnings galore Pin
Judah Gabriel Himango16-Aug-04 10:50
sponsorJudah Gabriel Himango16-Aug-04 10:50 
GeneralRe: VS 2005 beta - warnings galore Pin
Nick Parker16-Aug-04 10:58
protectorNick Parker16-Aug-04 10:58 
GeneralRe: VS 2005 beta - warnings galore Pin
Judah Gabriel Himango16-Aug-04 11:46
sponsorJudah Gabriel Himango16-Aug-04 11:46 
GeneralRe: VS 2005 beta - warnings galore Pin
LongRange.Shooter17-Aug-04 3:39
LongRange.Shooter17-Aug-04 3:39 
GeneralRe: VS 2005 beta - warnings galore Pin
Judah Gabriel Himango17-Aug-04 4:18
sponsorJudah Gabriel Himango17-Aug-04 4:18 
GeneralGhost windows Pin
Itay Sagui16-Aug-04 9:21
Itay Sagui16-Aug-04 9:21 
GeneralRe: Ghost windows Pin
Nick Parker16-Aug-04 10:03
protectorNick Parker16-Aug-04 10:03 
GeneralRe: Ghost windows Pin
Itay Sagui16-Aug-04 10:11
Itay Sagui16-Aug-04 10:11 
GeneralRe: Ghost windows Pin
Nick Parker16-Aug-04 10:24
protectorNick Parker16-Aug-04 10:24 
Questionusing ReflectionPermission to access Protected members? Pin
LongRange.Shooter16-Aug-04 9:00
LongRange.Shooter16-Aug-04 9:00 
GeneralDrop Down List within a Template Column footer in a DataGrid Pin
spaskewitz16-Aug-04 8:51
spaskewitz16-Aug-04 8:51 
Generallogging on desktop Pin
mathon16-Aug-04 7:28
mathon16-Aug-04 7:28 
GeneralRe: logging on desktop Pin
Dave Kreskowiak17-Aug-04 4:52
mveDave Kreskowiak17-Aug-04 4:52 
GeneralRe: logging on desktop Pin
mathon17-Aug-04 7:45
mathon17-Aug-04 7:45 
GeneralRe: logging on desktop Pin
Dave Kreskowiak18-Aug-04 8:37
mveDave Kreskowiak18-Aug-04 8:37 

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.