طباعة DataGridView من اليمين VB.NET
السلام عليكم.
حبيت اشاركم في مشكلة واجهتني عند طلب زبون لي خيار طباعة DataGridView في برنامج كنت قد أعددته له بواسطة vb.NET بإستخدام Visual Studio 2010 , وحلها.
المشكلة هيا ان البرنامج ومعلومات ال DataGridView بالعربية
أي يجب الطبعة من اليمين
~اولا~
نحمل من هنا DataGridViewPrinter.cs
أو عبر المرفقات.
ونفك الضغط (لنفترض فكناه في :c)
~ثانيا~
نبحث عن الملف: csc.exe وهو compiler لل #C.
الملف موجود عندي في:
~ثالثا~
نفتح command prompt أو cmd
ونحدد مسار csc.exe
~رابعا~
نكتب الأمر التالي:
هذا الامر يعمل compile ل DataGridViewPrinter.cs into DataGridViewPrinter.dll
~خامسا~
في VisualStudio نضع مرجع كالاتى:
تمام. تقريبا خلصنا :lol:
للتجربة:
-وضع form جديد
-وضع زيرين "Buttons"
-وضع DataGridView
-وضع برينتدكومنت (اسف هناك رقابة على كلمة دكومنت فالمنتدى)
نضع في خصائص ال datagridview
RightToLeft = True
وفالكود (بعد برمجة كيفية تعبأة ال datagridview أكيد) نضع الكود التالي:
(ايبدل ******** بـكلمة دكومنت بالإنجليزية)
//إنتهى
المرجع: هنا
والسلام عليكم ورحمة الله وبركاته
اخوكم في الله: SpookWEB
Sp00kY
حبيت اشاركم في مشكلة واجهتني عند طلب زبون لي خيار طباعة DataGridView في برنامج كنت قد أعددته له بواسطة vb.NET بإستخدام Visual Studio 2010 , وحلها.
المشكلة هيا ان البرنامج ومعلومات ال DataGridView بالعربية
أي يجب الطبعة من اليمين
~اولا~
نحمل من هنا DataGridViewPrinter.cs
أو عبر المرفقات.
ونفك الضغط (لنفترض فكناه في :c)
~ثانيا~
نبحث عن الملف: csc.exe وهو compiler لل #C.
الملف موجود عندي في:
كود:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319
~ثالثا~
نفتح command prompt أو cmd
كود:
CTRL+R -> CMD.exe
ونحدد مسار csc.exe
كود:
cd "C:\Windows\Microsoft.NET\Framework64\v4.0.30319"
~رابعا~
نكتب الأمر التالي:
كود:
csc /t:library /out:C:/DataGridViewPrinter.dll C:\DataGridViewPrinter.cs
~خامسا~
في VisualStudio نضع مرجع كالاتى:
كود:
Right-Click on your Project Name-> Add Reference -> Browse -> c:\DatagridViewerPrinter.dll
تمام. تقريبا خلصنا :lol:
للتجربة:
-وضع form جديد
-وضع زيرين "Buttons"
-وضع DataGridView
-وضع برينتدكومنت (اسف هناك رقابة على كلمة دكومنت فالمنتدى)
نضع في خصائص ال datagridview
RightToLeft = True
وفالكود (بعد برمجة كيفية تعبأة ال datagridview أكيد) نضع الكود التالي:
(ايبدل ******** بـكلمة دكومنت بالإنجليزية)
كود:
Public Class Form1
'Create DataGridViewPrinter type variable
Dim MyDataGridViewPrinter As DataGridViewPrinter
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If SetupThePrinting() Then
Print********1.Print()
End If
End Sub
'The PrintPage action for the Print******** control
Private Sub Print********1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles Print********1.PrintPage
Dim more As Boolean = MyDataGridViewPrinter.DrawDataGridView(e.Graphics)
If more = True Then
e.HasMorePages = True
End If
End Sub
'The PrintView button
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If SetupThePrinting() Then
Dim MyPrintPreviewDialog As PrintPreviewDialog = New PrintPreviewDialog()
MyPrintPreviewDialog.******** = Print********1
MyPrintPreviewDialog.ShowDialog()
End If
End Sub
Private Function SetupThePrinting() As Boolean
Dim MyPrintDialog As PrintDialog = New PrintDialog()
MyPrintDialog.AllowCurrentPage = False
MyPrintDialog.AllowPrintToFile = False
MyPrintDialog.AllowSelection = False
MyPrintDialog.AllowSomePages = False
MyPrintDialog.PrintToFile = False
MyPrintDialog.ShowHelp = False
MyPrintDialog.ShowNetwork = False
If MyPrintDialog.ShowDialog() <> DialogResult.OK Then
Return False
End If
Print********1.********Name = "Customers Report"
Print********1.PrinterSettings = MyPrintDialog.PrinterSettings
Print********1.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings
Print********1.DefaultPageSettings.Margins = New Margins(40, 40, 40, 40)
If MessageBox.Show("Do you want the report to be centered on the page", "InvoiceManager - Center on Page", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
MyDataGridViewPrinter = New DataGridViewPrinter(DataGridView1, Print********1, True, True, "Customers", New Font("Tahoma", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, True)
Else
MyDataGridViewPrinter = New DataGridViewPrinter(DataGridView1, Print********1, False, True, "Customers", New Font("Tahoma", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, True)
End If
Return True
End Function
//إنتهى
كود:
Tested on
Windows 7 x32
VisualStudio 2010 Ultimate
Microsoft.NET Framework 4 Client Profile 4.0.30319.1 Final
المرجع: هنا
والسلام عليكم ورحمة الله وبركاته
اخوكم في الله: SpookWEB
Sp00kY
المرفقات
اسم الموضوع : طباعة DataGridView من اليمين VB.NET
|
المصدر : قسم البرمجة الكائنية
