10-04-17, 01:43 AM
(10-04-17, 01:20 AM)abdualla كتب : تفضل التعديل
PHP كود :
Private products As New Dictionary(Of String, String)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
DataGridView1.ColumnCount = 3
DataGridView1.Columns(0).Name = "id"
DataGridView1.Columns(1).Name = " Name"
DataGridView1.Columns(2).Name = "Price"
DataGridView1.Rows.Add("1", "Product 1", "1000")
DataGridView1.Rows.Add("2", "Product 1", "2000")
DataGridView1.Rows.Add("3", "Product 1", "3000")
DataGridView1.Rows.Add("4", "Product 4", "4000")
DataGridView1.Rows.Add("5", "Product 5", "5000")
For Each r As DataGridViewRow In Me.DataGridView1.Rows
If r.IsNewRow Then Exit For
Dim p As String = r.Cells(1).Value
If Not products.Keys.Contains(p) Then products.Add(p, "")
Next
For i = 0 To products.Count - 1
For Each r As DataGridViewRow In Me.DataGridView1.Rows
If r.IsNewRow Then Exit For
Dim k As String = r.Cells(1).Value
Dim v As String = r.Cells(2).Value
If products.Keys(i) = k Then
products(k) = products(k) & "Call: " & v & vbNewLine
End If
Next
Next
End Sub
Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim leftMargin As Integer = e.MarginBounds.Left
Dim topMargin As Integer = e.MarginBounds.Top
Dim cellFont As New Font("Arial", 14)
Dim cellForeColor As New SolidBrush(Color.Black)
Dim cellBackColor As New SolidBrush(Color.WhiteSmoke)
Dim cellBorderColor As New Pen(Brushes.Blue, 1)
Dim cellSize As New Size(300, 100)
Dim index As Integer = 0
For currentY = 0 To (products.Count - 1) \ 2
For currentX = 0 To 1
Dim cellText As String =
"confirming QSO with " & products.Keys(index) & vbNewLine & _
products(products.Keys(index))
Dim cellPoint As New Point(leftMargin + (currentX * cellSize.Width), topMargin + (currentY * cellSize.Height))
Dim cellRectangle As New Rectangle(cellPoint, cellSize)
e.Graphics.FillRectangle(cellBackColor, cellRectangle)
e.Graphics.DrawString(cellText.Trim, cellFont, cellForeColor, cellRectangle)
e.Graphics.DrawRectangle(cellBorderColor, cellRectangle)
index += 1
If index = products.Count Then Exit For
Next
Next
End Sub
احسنت كفيت ووفيت جزاك الله خير
شكرا واسمحلي على تعبك
الحمدالله والشكر
لا ننحرم منك
في ميزان اعمالك

