Search code snippets, questions, articles...

تشكيل جدول بالاعتماد على كلاس Person

Public Class Form1
    Dim ListPersons As New List(Of Person)

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ListPersons = ListOfPersons()
        Dgv1.DataSource = ListPersons.ToList
    End Sub



    Private Function CreateDatTable() As DataTable
        Dim Dt As New DataTable()
        Dim Colum1 As DataColumn = New DataColumn With {.ColumnName = "Name", .DataType = Type.GetType("System.String")}
        Dim Colum2 As DataColumn = New DataColumn With {.ColumnName = "Phone", .DataType = Type.GetType("System.String")}
        Dt.Columns.Add(Colum1)
        Dt.Columns.Add(Colum2)



        For i As Integer = 1 To 500
            Dim p As Integer = i
            If p = Names.Length - 1 Then p = 0
            Dim Data() As String = New String() {i, Names(p), Strat(p)}
            Dt.Rows.Add(Data)
        Next
        Return Dt

    End Function

    Dim Names() As String = New String() {"علي", "احمد", "محمد", "سالم", "فهد", "بدر", "اصيل", "عبد الله", "ربيع", "مريم", "خالد", "راشد", "سيف", "ناصر", "وحيد", "معتز"}
    Dim Strat() As String = New String() {"سباحة", "كرة قدم", "كرة سلة", "رماية", "فروسية", "مطالعة", "سفر", "برمجة", "قيادة", "كرة يد", "قفز", "تصوير", "رسم", "نحت", "ديكور", "تمثيل"}

    Private Function ListOfPersons() As List(Of Person)
        Dim p As Integer

        Dim Random As Random = New Random()

        For i As Integer = 1 To 500

            If i >= Names.Length AndAlso p >= Names.Length Then p = 0
            Dim x As Integer = Random.Next(p, Names.Length)
            Dim z As Integer = Random.Next(p, Strat.Length)

            Dim Prs As New Person With {.ID = i, .Name = Names(x), .Phone = Strat(z)}
            ListPersons.Add(Prs)
            p += 1
        Next
        Return ListPersons
    End Function


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        'If Dt_Laters.Rows.Count > 0 Then
        'نسخة من الريبورت
        Dim Rpt As New XtraReport1

        'Dim Dt_Company As DataTable = AssociationInfoCls.GetInstance.SelectAll
        'اسناد معلومات الشركة
        'If Dt_Company.Rows.Count > 0 Then
        '        'Rpt.XrAf_Name.Text = Dt_Company.Rows(0)("Af_Name")
        '        'Rpt.XrAf_Tel1.Text = "هاتف: " & Dt_Company.Rows(0)("Af_Tel1")
        '        'Rpt.XrAf_Adrs.Text = "العنوان: " & Dt_Company.Rows(0)("Af_Adrs")
        '        'Rpt.XrAf_Mobile1.Text = "جوال: " & Dt_Company.Rows(0)("Af_Mobile1")
        '    Else
        '        'XtraMessageBox.Show(DevExpress.LookAndFeel.UserLookAndFeel.Default, "لا يوجد معلومات رأسية للشركة حاول اضافة معلومات عن الشركة", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        '    End If


        Rpt.RequestParameters = False
            Rpt.DataSource = ListPersons
            ' Rpt.DataMember = "Print_CustNotPayes"

            'اغلاق الفورم اذا كان مفتوح
            'If My.Application.OpenForms.OfType(Of Fr_RptViewer).Any() Then
            '    For Each Item As Form In DocumentManager.FromControl(RibbonForm1).MdiParent.MdiChildren
            '        If String.Equals(Item.Name, "Fr_RptViewer") Then
            '            Item.Close()
            '        End If
            '    Next
            'End If


            XtraForm1.DocumentViewer1.DocumentSource = Rpt
            ' Fr_RptViewer.GetInstance.MdiParent = RibbonForm1
            XtraForm1.Show()
        'Else
        '    XtraMessageBox.Show(DevExpress.LookAndFeel.UserLookAndFeel.Default, "لا يوجد معلومات لطباعتها", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        '    Exit Sub


        'End If



    End Sub
End Class

Search Index Data (The code snippet can also be found with below search text)

person,class
Was this helpful?
0 Comments
Programming Feeds
Learn something new everyday on Devsheet