تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[VB.NET] لمن يبحث على كود طباعة اي صف في داتا قريد تفضل
#1
السلام عليكم

لمن يبحث عن كود طباعة اي صف في datagridview تفضل ارجوا الدعاء وجزاكم الله خيرا

المشروع
يحتوي على datagridview
2 button
form1 يتم وضع فيه الادوات السابقة الذكر
form2 يوضع  فيه  
crystalreportview

نضع الكود التالي
Imports System.Data.OleDb
Imports System.Data
Public Class Form1
    Public position As Integer

    Public con As New OleDbConnection("provider=microsoft.jet.oledb.4.0; data source = " & Application.StartupPath & "\info.mdb")
    Public da As New OleDbDataAdapter
    Public ds As New DataSet
    Public dt As New DataTable



  Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'table1_load()
        Try

            Dim data As New OleDbDataAdapter("select * from table1", con)

            ds.Clear()

            con.Open()

            data.Fill(ds, "ppp")

            con.Close()

            DataGridView1.DataSource = ds.Tables("ppp")

            add()

        Catch ex As Exception

            MsgBox(ex.Message)

        Finally

            con.Close()

        End Try

    End Sub
    Sub add()

        Dim field As New DataGridViewCheckBoxColumn

        field.HeaderText = "اختر الطباعة"

        DataGridView1.Columns.Insert(9, field)

    End Sub

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

            Me.Cursor = Cursors.WaitCursor

            Dim x As New Form2

            x.print(ds, "ppp")

            x.Show()

            Me.Cursor = Cursors.Default

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Try

            Me.Cursor = Cursors.WaitCursor

            dt = New DataTable

            dt.TableName = "sss"

            dt.Columns.Clear()

            add2()

            Dim count As Integer = 0

            Dim dr As DataRow

            For i = 0 To DataGridView1.Rows.Count - 1

                If DataGridView1.Item(9, i).Value = True Then

                    dr = dt.Rows.Add

                    dr.Item("Cv_Id") = DataGridView1.Item(0, i).Value.ToString
                    dr.Item("Cv_FullName") = DataGridView1.Item(1, i).Value.ToString
                    dr.Item("Cv_Birthday") = DataGridView1.Item(2, i).Value.ToString
                    dr.Item("Cv_PlaceOfBirth") = DataGridView1.Item(3, i).Value.ToString
                    dr.Item("Cv_BloodType") = DataGridView1.Item(4, i).Value.ToString
                    dr.Item("Cv_Father") = DataGridView1.Item(5, i).Value.ToString
                    dr.Item("Cv_Phone") = DataGridView1.Item(6, i).Value.ToString
                    dr.Item("Cv_Gender") = DataGridView1.Item(7, i).Value.ToString



                    count += 1

                End If

            Next

            If count = 0 Then

                MsgBox("لم تقم بإختيار أي عنصر للطباعة", MsgBoxStyle.Exclamation)

                Exit Sub

            End If

            Dim dss As New DataSet

            dss.Clear()

            dss.Tables.Add(dt)

            Dim r As New Form2

            r.print(dss, "sss")

            removecheck()

            r.Show()

        Catch ex As Exception

            MsgBox(ex.Message)

        Finally

            Me.Cursor = Cursors.Default

        End Try

    End Sub
    Sub add2()

        Dim Name As DataColumn = New DataColumn("Cv_Id")

        Name.DataType = System.Type.GetType("System.String")

        dt.Columns.Add(Name)

        Dim age As DataColumn = New DataColumn("Cv_FullName")

        age.DataType = System.Type.GetType("System.String")

        dt.Columns.Add(age)

        Dim job As DataColumn = New DataColumn("Cv_Birthday")

        job.DataType = System.Type.GetType("System.String")

        dt.Columns.Add(job)

        Dim car As DataColumn = New DataColumn("Cv_PlaceOfBirth")

        car.DataType = System.Type.GetType("System.String")

        dt.Columns.Add(car)

        Dim lang As DataColumn = New DataColumn("Cv_BloodType")

        lang.DataType = System.Type.GetType("System.String")

        dt.Columns.Add(lang)

        Dim lang1 As DataColumn = New DataColumn("Cv_Father")

        lang1.DataType = System.Type.GetType("System.String")

        dt.Columns.Add(lang1)

        Dim lang2 As DataColumn = New DataColumn("Cv_Phone")

        lang2.DataType = System.Type.GetType("System.String")

        dt.Columns.Add(lang2)

        Dim lang3 As DataColumn = New DataColumn("Cv_Gender")

        lang3.DataType = System.Type.GetType("System.String")

        dt.Columns.Add(lang3)

    End Sub
    Sub removecheck()

        For i = 0 To DataGridView1.Rows.Count - 1

            DataGridView1.Item(9, i).Value = False

        Next

    End Sub



اي استفسار ارجوا ترك تعليق
السلام عليكم ورحمة الله وبركاته
الرد
تم الشكر بواسطة: كريم عبودي



التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم