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

عدم ظهور الالوان فى الطباعة

بدأه nadiagamal في 8 فبراير 2014 · 7 رد · 385 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم عندما قمت باستخدام اداة الطباعة  PrintDocument1    لطباعة من جريد فيو  ولكن  لم اتمكن من طباعة النصوص باللوان

 

777.png

 

 

 

ا Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        Dim bm As New Bitmap(Me.DataGridView1.Width, Me.DataGridView1.Height)
        DataGridView1.DrawToBitmap(bm, New Rectangle(0, 0, Me.DataGridView1.Width, Me.DataGridView1.Height))
        e.Graphics.DrawImage(bm, 0, 0)



    End Sub

 

 

 

 

 

 

فانا بكتب الكوده وهى بتطلع بالوا عادى فى جرد فيو ولكن مش بتطلع اللوان فى البطاعة

 

 Try


            For mdg = 0 To DataGridView3.Rows.Count - 1


                If DataGridView3.Rows(mdg).Cells(1).Value = "MM" Then
                    DataGridView3.Rows(mdg).Cells(1).Style.BackColor = Color.Green

                End If
            Next


        Catch ex As Exception

        End Try

 

 

هل يوجد لها هل

#2

صعبة ومعقدة صح

#3

انا وصلت للكوده ده من النت

 

 

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

        'Dim bm As New Bitmap(DataGridView3.Width, DataGridView3.Height)
        'DataGridView3.DrawToBitmap(bm, New Rectangle(0, 0, DataGridView3.Width, DataGridView3.Height))
        'e.Graphics.DrawImage(bm, 10, 10)



        With DataGridView1
            Dim fmt As StringFormat = New StringFormat(StringFormatFlags.LineLimit)
            fmt.LineAlignment = StringAlignment.Center
            fmt.Trimming = StringTrimming.EllipsisCharacter
            Dim y As Single = e.MarginBounds.Top
            Do While mRow < .RowCount
                Dim row As DataGridViewRow = .Rows(mRow)
                Dim x As Single = e.MarginBounds.Left
                Dim h As Single = 0
                For Each cell As DataGridViewCell In row.Cells
                    Dim rc As RectangleF = New RectangleF(x, y, cell.Size.Width, cell.Size.Height)
                    e.Graphics.DrawRectangle(Pens.Black, rc.Left, rc.Top, rc.Width, rc.Height)


                    If (newpage) Then
                        e.Graphics.DrawString(DataGridView1.Columns(cell.ColumnIndex).HeaderText, .Font, Brushes.Black, rc, fmt)
                    Else
                        e.Graphics.DrawString(DataGridView1.Rows(cell.RowIndex).Cells(cell.ColumnIndex).FormattedValue.ToString(), .Font, Brushes.Black, rc, fmt)
                    End If


 















                    x += rc.Width
                    h = Math.Max(h, rc.Height)
                Next
                newpage = False
                y += h
                mRow += 1
                If y + h > e.MarginBounds.Bottom Then
                    e.HasMorePages = True
                    mRow -= 1
                    newpage = True
                    Exit Sub
                End If
            Loop
            mRow = 0
        End With





        'Dim y2 As Single = e.MarginBounds.Top
        'Dim row2 As DataGridViewRow = .Rows(mRow)
        'Dim x2 As Single = e.MarginBounds.Left
        'Dim h2 As Single = 0
        'Dim fmt2 As StringFormat = New StringFormat(StringFormatFlags.LineLimit)
        'fmt2.LineAlignment = StringAlignment.Center
        'fmt2.Trimming = StringTrimming.EllipsisCharacter

        'For idddddd = 0 To DataGridView1.Rows.Count - 1

        '    Dim rc2 As RectangleF = New RectangleF(x2, y2, , cell.Size.Height)

        '    If DataGridView1.Rows(idddddd).Cells(2).Value = "G" Then
        '        DataGridView1.Rows(idddddd).Cells(2).Style.BackColor = Color.Red
        '        e.Graphics.DrawString(DataGridView1.Rows(idddddd).Cells(2).FormattedValue.ToString(), .Font, Brushes.Red, rc2, fmt2)

        '    End If
        'Next

    End Sub
 

 

 

وكل شيىء تمام ولكن الطباعة كلها بتطلع بلون اسود

 

 

وانا عاملة برمجة بحيث تطلع فى داتا جريد خلايا معينة بلون احمر فى حدا ما وده الكود بتاعها اوكى

 

 

'For idddddd = 0 To DataGridView1.Rows.Count - 1

        '    Dim rc2 As RectangleF = New RectangleF(x2, y2, , cell.Size.Height)

        '    If DataGridView1.Rows(idddddd).Cells(2).Value = "G" Then
        '        DataGridView1.Rows(idddddd).Cells(2).Style.BackColor = Color.Red
        '        e.Graphics.DrawString(DataGridView1.Rows(idddddd).Cells(2).FormattedValue.ToString(), .Font, Brushes.Red, rc2, fmt2)

        '    End If
        'Next
 

 

دلوقتى بقى حبيت احطه مع الكود الشابق طلعت الشكل ده

وعاملى التكرار

 

 

bbbbbbbbb.jpg

سؤال هل مساعدة بعدم التكرر

#4

هههههههههههههههههههههههههههههههههههههههه

 

لائيتها  واتضبتطط بنجاااااااااااااااح

 

الحمد لله

 

 

الكود اهو لاستفادة اوكى

 

If (newpage) Then
                        e.Graphics.DrawString(DataGridView1.Columns(cell.ColumnIndex).HeaderText, .Font, Brushes.Black, rc, fmt)
                    Else

                        If DataGridView1.Rows(cell.RowIndex).Cells(2).Value = "G" Then
                            '        DataGridView1.Rows(idddddd).Cells(2).Style.BackColor = Color.Red

                            e.Graphics.DrawString(DataGridView1.Rows(cell.RowIndex).Cells(cell.ColumnIndex).FormattedValue.ToString(), .Font, Brushes.Red, rc, fmt)
                        Else

                            e.Graphics.DrawString(DataGridView1.Rows(cell.RowIndex).Cells(cell.ColumnIndex).FormattedValue.ToString(), .Font, Brushes.Black, rc, fmt)

                        End If



                    End If
 

 

على فكرة ناقصلى حاجة تانية وهى انا عايزة اعمل عمود معين بلون الاصفر دى وبس

اللى يعرف يقول واللى ما يعرفش فاحاول انا ولو لاقيتها هاحطها والله المستعان

#5

التجربة فشلت ياريت اللى عنده مساعدة وشكرا

#6

اين الحكماااااااااااااااااااااااااااااء والخبراااااااااااااااء

#7

الووووووووو

#8

ارجو استخدام تنسيق الاكواد فى الكتابة حتى يمكن قراءته بسهوله اولا

VB.NET and C# Comparison

http://www.harding.edu/fmccown/vbnet_csharp_comparison.html

002.gif

=-=-=-=-=-=-=
ذو العلم يشقى فى النعيم بعلمه .:. واخو الجهالة فى الشقاوة ينعم
=-=-=-=-=-=-=
يا من بدنياه اشتغل . قد غره طول الأمل . فالموت يأتى بغتة . والقبر صندوق العمل
=-=-=-=-=-=-=
ان لم تستطع ان تجد ما تفعله فافعل ما لم تسطع ان تجده

screen_shot_2011-05-19_at_12.44.49_pm.pn

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