الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

اريد قلب طباعة الداتا جريد من اليسار الي اليمين

بدأه usamah_gg في 1 مارس 2012 · 2 رد · 428 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم و رحمة الله وبركاتة

سؤالي هو كيف اقلب طباعة الداتا جريد من اليسار الي اليمين الي من اليمين لليسار في هذا الكود

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

PrintPreviewDialog1.Document = PrintDocument1

PrintDocument1.DocumentName = "Test Page Print"

Me.PrintPreviewDialog1.ShowDialog()

End Sub

Private Sub PrintDocument1_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.BeginPrint

Try

strFormat = New StringFormat()

strFormat.Alignment = StringAlignment.Near

strFormat.LineAlignment = StringAlignment.Center

strFormat.Trimming = StringTrimming.EllipsisCharacter

arrColumnLefts.Clear()

arrColumnWidths.Clear()

iCellHeight = 0

iRow = 0

bFirstPage = True

bNewPage = True

iTotalWidth = 0

For Each dgvGridCol As DataGridViewColumn In DataGridView1.Columns

iTotalWidth += dgvGridCol.Width

Next

Catch ex As Exception

MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])

End Try

End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

Try

Dim iLeftMargin As Integer = e.MarginBounds.Left

Dim iTopMargin As Integer = e.MarginBounds.Top

Dim bMorePagesToPrint As Boolean = False

Dim iTmpWidth As Integer = 0

If bFirstPage Then

For Each GridCol As DataGridViewColumn In DataGridView1.Columns

iTmpWidth = Math.Floor(GridCol.Width / iTotalWidth * iTotalWidth * e.MarginBounds.Width / iTotalWidth)

iHeaderHeight = e.Graphics.MeasureString(GridCol.HeaderText, GridCol.InheritedStyle.Font, iTmpWidth).Height + 11

arrColumnLefts.Add(iLeftMargin)

arrColumnWidths.Add(iTmpWidth)

iLeftMargin += iTmpWidth

Next

End If

While iRow <= DataGridView1.Rows.Count - 1

Dim GridRow As DataGridViewRow = DataGridView1.Rows(iRow)

iCellHeight = GridRow.Height + 5

Dim iCount As Integer = 0

If iTopMargin + iCellHeight >= e.MarginBounds.Height + e.MarginBounds.Top Then

bNewPage = True

bFirstPage = False

bMorePagesToPrint = True

Exit While

Else

If bNewPage Then

e.Graphics.DrawString(companynam, New Font(DataGridView1.Font, FontStyle.Bold), Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top - e.Graphics.MeasureString("Customer Summary", New Font(DataGridView1.Font, FontStyle.Bold), e.MarginBounds.Width).Height - 13)

Dim strDate As String = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString()

e.Graphics.DrawString(strDate, New Font(DataGridView1.Font, FontStyle.Bold), Brushes.Black, e.MarginBounds.Left + (e.MarginBounds.Width - e.Graphics.MeasureString(strDate, New Font(DataGridView1.Font, FontStyle.Bold), e.MarginBounds.Width).Width), e.MarginBounds.Top - e.Graphics.MeasureString("Customer Summary", New Font(New Font(DataGridView1.Font, FontStyle.Bold), FontStyle.Bold), e.MarginBounds.Width).Height - 13)

iTopMargin = e.MarginBounds.Top

For Each GridCol As DataGridViewColumn In DataGridView1.Columns

e.Graphics.FillRectangle(New SolidBrush(Color.LightGray), New Rectangle(DirectCast(arrColumnLefts(iCount), Integer), iTopMargin, DirectCast(arrColumnWidths(iCount), Integer), iHeaderHeight))

e.Graphics.DrawRectangle(Pens.Black, New Rectangle(DirectCast(arrColumnLefts(iCount), Integer), iTopMargin, DirectCast(arrColumnWidths(iCount), Integer), iHeaderHeight))

e.Graphics.DrawString(GridCol.HeaderText, GridCol.InheritedStyle.Font, New SolidBrush(GridCol.InheritedStyle.ForeColor), New RectangleF(DirectCast(arrColumnLefts(iCount), Integer), iTopMargin, DirectCast(arrColumnWidths(iCount), Integer), iHeaderHeight), strFormat)

System.Math.Max(System.Threading.Interlocked.Increment(iCount), iCount - 1)

Next

bNewPage = False

iTopMargin += iHeaderHeight

End If

iCount = 0

For Each Cel As DataGridViewCell In GridRow.Cells

If Not Cel.Value Is Nothing Then

e.Graphics.DrawString(Cel.Value.ToString(), Cel.InheritedStyle.Font, New SolidBrush(Cel.InheritedStyle.ForeColor), New RectangleF(DirectCast(arrColumnLefts(iCount), Integer), DirectCast(iTopMargin, Integer), DirectCast(arrColumnWidths(iCount), Integer), DirectCast(iCellHeight, Integer)), strFormat)

End If

e.Graphics.DrawRectangle(Pens.Black, New Rectangle(DirectCast(arrColumnLefts(iCount), Integer), iTopMargin, DirectCast(arrColumnWidths(iCount), Integer), iCellHeight))

System.Math.Max(System.Threading.Interlocked.Increment(iCount), iCount - 1)

Next

End If

System.Math.Max(System.Threading.Interlocked.Increment(iRow), iRow - 1)

iTopMargin += iCellHeight

End While

If bMorePagesToPrint Then

e.HasMorePages = True

Else

e.HasMorePages = False

End If

Catch exc As Exception

MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])

End Try

End Sub

وشكراً لتعاونكم

تم تعديل هذه المشاركة بواسطة usamah_gg في 2 مارس 2012 في 02:36

#2

في خصائص الفرمه يوجد RightToLeft اجعلها نعم

تم تعديل هذه المشاركة بواسطة KARIMSOFT في 4 مارس 2012 في 02:25

#3
KARIMSOFT كتب:

في خصائص الفرمه يوجد RightToLeft اجعلها نعم

يا اخي العزيز في الفورم كل شي مظبوط لكن اذا سسويت امر طباعة تخرج النتيجة من اليسار لليمين

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…