منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
كيفية اضافة صورة لزر في الداتا قريد فيو - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183)
+--- الموضوع : كيفية اضافة صورة لزر في الداتا قريد فيو (/showthread.php?tid=23701)



كيفية اضافة صورة لزر في الداتا قريد فيو - المتألق9 - 06-02-18

السلام عليكم
اريد طريقة اضافة صورة لزر في الداتا قريد فيو 
وشكرا


RE: كيفية اضافة صورة لزر في الداتا قريد فيو - طالب برمجة - 06-02-18

استخدم 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 



RE: كيفية اضافة صورة لزر في الداتا قريد فيو - المتألق9 - 06-02-18

(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 

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


RE: كيفية اضافة صورة لزر في الداتا قريد فيو - بسام محمدغانم - 28-12-19

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