PDA

View Full Version : نحوه کار باprint preview dialog , printpreviewcontrol



anahita6
سه شنبه 08 اردیبهشت 1388, 12:05 عصر
:گریه::گریه::گریه::گریه::گریه: :گریه::گریه::گریه::گریه::گریه: :گریه::گریه::گریه::گریه::گریه: :گریه::گریه::گریه::گریه::گریه: :گریه::گریه::گریه::گریه::گریه: :گریه::گریه::گریه::گریه::گریه: :گریه::گریه::گریه::گریه::گریه: :گریه::گریه::گریه::گریه::گریه: :گریه::گریه::گریه::گریه::گریه: :گریه::گریه::گریه::گریه::گریه: :گریه::گریه::گریه::گریه::گریه: :گریه::گریه::گریه::گریه::گریه: :گریه::گریه::گریه::گریه::گریه: :گریه::گریه::گریه::گریه:



سلام بچه ها
نحوه کار باprint preview dialog , printpreviewcontrol چه جوریه اگه کسی میدونه یا مقاله ای داره بی زحمت کمکم کنه

anahita6
سه شنبه 08 اردیبهشت 1388, 17:46 عصر
یعنی کسی کار با این کنترل رو بلد نیست؟

captain_black81
سه شنبه 08 اردیبهشت 1388, 17:58 عصر
private void InitializePrintPreviewControl()
{

// Construct the PrintPreviewControl.
this.PrintPreviewControl1 = new PrintPreviewControl();

// Set location, name, and dock style for PrintPreviewControl1.
this.PrintPreviewControl1.Location = new Point(88, 80);
this.PrintPreviewControl1.Name = "PrintPreviewControl1";
this.PrintPreviewControl1.Dock = DockStyle.Fill;

// Set the Document property to the PrintDocument
// for which the PrintPage event has been handled.
this.PrintPreviewControl1.Document = docToPrint;

// Set the zoom to 25 percent.
this.PrintPreviewControl1.Zoom = 0.25;

// Set the document name. This will show be displayed when
// the document is loading into the control.
this.PrintPreviewControl1.Document.DocumentName = "c:\\someFile";

// Set the UseAntiAlias property to true so fonts are smoothed
// by the operating system.
this.PrintPreviewControl1.UseAntiAlias = true;

// Add the control to the form.
this.Controls.Add(this.PrintPreviewControl1);

// Associate the event-handling method with the
// document's PrintPage event.
this.docToPrint.PrintPage +=
new System.Drawing.Printing.PrintPageEventHandler(
docToPrint_PrintPage);
}

anahita6
سه شنبه 08 اردیبهشت 1388, 18:04 عصر
متشکر
حالا اگه بخوام یه فیلد رو از پایگاه داده بخونم و توی قسمتی از print preview قرار بدم چیکار باید بکنم

captain_black81
سه شنبه 08 اردیبهشت 1388, 18:37 عصر
امیدوارم این کمک کنه


private void docToPrint_PrintPage(
object sender, System.Drawing.Printing.PrintPageEventArgs e)
{

// Insert code to render the page here.
// This code will be called when the control is drawn.

// The following code will render a simple
// message on the document in the control.
string text = "In docToPrint_PrintPage method.";
System.Drawing.Font printFont =
new Font("Arial", 35, FontStyle.Regular);

e.Graphics.DrawString(text, printFont,
Brushes.Black, 10, 10);
}

anahita6
چهارشنبه 09 اردیبهشت 1388, 11:04 صبح
امیدوارم این کمک کنه


private void docToPrint_PrintPage(
object sender, System.Drawing.Printing.PrintPageEventArgs e)
{

// Insert code to render the page here.
// This code will be called when the control is drawn.

// The following code will render a simple
// message on the document in the control.
string text = "In docToPrint_PrintPage method.";
System.Drawing.Font printFont =
new Font("Arial", 35, FontStyle.Regular);

e.Graphics.DrawString(text, printFont,
Brushes.Black, 10, 10);
}



مرسی اما این کد چه ربطی به ترنزکت گرفتن از sqlداره . من میخوام یه فیلد رو از یه پایگاه داده بگیرم و اون رو در printpreviewچاپ کنم

captain_black81
چهارشنبه 09 اردیبهشت 1388, 11:41 صبح
خب میتونید او text رو از sql بیارید