منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : كيفية اضافة صورة لزر في الداتا قريد فيو
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
السلام عليكم
اريد طريقة اضافة صورة لزر في الداتا قريد فيو 
وشكرا
استخدم DataGridViewImageColumn بدلا من DataGridViewButtonColumn لتستطيع إضافة الصورة بدون كود

هذا الكود لإضافة صورة في العمود الثالت (e.ColumnIndex = 2) عن طريق الحدث CellPainting
PHP كود :
Private Sub DataGridView1_CellPainting(ByVal sender As ObjectByVal e As DataGridViewCellPaintingEventArgsHandles DataGridView1.CellPainting
    e
.Paint(e.CellBoundsDataGridViewPaintParts.All)

 
   If e.RowIndex >= 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(lftrgt)
 
       e.Graphics.DrawImage(img, New Rectangle(pntsiz))
 
   End If

 
   e.Handled True
End Sub 
(06-02-18, 01:40 PM)طالب برمجة كتب : [ -> ]استخدم DataGridViewImageColumn بدلا من DataGridViewButtonColumn لتستطيع إضافة الصورة بدون كود

هذا الكود لإضافة صورة في العمود الثالت (e.ColumnIndex = 2) عن طريق الحدث CellPainting
PHP كود :
Private Sub DataGridView1_CellPainting(ByVal sender As ObjectByVal e As DataGridViewCellPaintingEventArgsHandles DataGridView1.CellPainting
    e
.Paint(e.CellBoundsDataGridViewPaintParts.All)

 
   If e.RowIndex >= 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(lftrgt)
 
       e.Graphics.DrawImage(img, New Rectangle(pntsiz))
 
   End If

 
   e.Handled True
End Sub 

شكرا أخي العزيز
ولكن عند تنفيذ الكود تظهر الصورة أكبر من الزر 
هل يوجد حل
يا استاذي اريد الداتاجريد فيو تستقبل صور كيف يكون الكود
طبعا الصور بيكون من خلال مسار في الشروع 
ويضهر كل الصور في الملف من خلال المسار المحدد له