06-02-18, 11:31 AM
06-02-18, 01:40 PM
استخدم DataGridViewImageColumn بدلا من DataGridViewButtonColumn لتستطيع إضافة الصورة بدون كود
هذا الكود لإضافة صورة في العمود الثالت (e.ColumnIndex = 2) عن طريق الحدث CellPainting
هذا الكود لإضافة صورة في العمود الثالت (e.ColumnIndex = 2) عن طريق الحدث CellPainting
PHP كود :
Private Sub DataGridView1_CellPainting(ByVal sender As Object, ByVal e As DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting
e.Paint(e.CellBounds, DataGridViewPaintParts.All)
If e.RowIndex >= 0 And e.ColumnIndex = 2 Then
Dim wid As Integer = e.CellBounds.Width
Dim hig As Integer = e.CellBounds.Height
Dim img As Image = My.Resources.icon
Dim siz As Size = img.Size
Dim lft As Integer = e.CellBounds.Left + CInt((wid - siz.Width) / 2)
Dim rgt As Integer = e.CellBounds.Top + CInt((hig - siz.Height) / 2)
Dim pnt As New Point(lft, rgt)
e.Graphics.DrawImage(img, New Rectangle(pnt, siz))
End If
e.Handled = True
End Sub
06-02-18, 03:35 PM
(06-02-18, 01:40 PM)طالب برمجة كتب : [ -> ]استخدم DataGridViewImageColumn بدلا من DataGridViewButtonColumn لتستطيع إضافة الصورة بدون كود
هذا الكود لإضافة صورة في العمود الثالت (e.ColumnIndex = 2) عن طريق الحدث CellPainting
PHP كود :
Private Sub DataGridView1_CellPainting(ByVal sender As Object, ByVal e As DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting
e.Paint(e.CellBounds, DataGridViewPaintParts.All)
If e.RowIndex >= 0 And e.ColumnIndex = 2 Then
Dim wid As Integer = e.CellBounds.Width
Dim hig As Integer = e.CellBounds.Height
Dim img As Image = My.Resources.icon
Dim siz As Size = img.Size
Dim lft As Integer = e.CellBounds.Left + CInt((wid - siz.Width) / 2)
Dim rgt As Integer = e.CellBounds.Top + CInt((hig - siz.Height) / 2)
Dim pnt As New Point(lft, rgt)
e.Graphics.DrawImage(img, New Rectangle(pnt, siz))
End If
e.Handled = True
End Sub
شكرا أخي العزيز
ولكن عند تنفيذ الكود تظهر الصورة أكبر من الزر
هل يوجد حل
28-12-19, 06:32 AM
يا استاذي اريد الداتاجريد فيو تستقبل صور كيف يكون الكود
طبعا الصور بيكون من خلال مسار في الشروع
ويضهر كل الصور في الملف من خلال المسار المحدد له
طبعا الصور بيكون من خلال مسار في الشروع
ويضهر كل الصور في الملف من خلال المسار المحدد له