07-01-16, 08:08 AM
(07-01-16, 12:52 AM)حريف برمجة كتب : وعليكم السلام ورحمة الله وبركاته
اقترح عليك استبدل الليست فيو بداتا قريد فيو ..
جميل جداً وبيمشي تمام ولكني جعلته أخر الحلول
(07-01-16, 06:11 AM)الماجيك مسعد كتب : Try
Dim red As New OpenFileDialog()
red.Filter = "Choose Image(*.jpg; *.png; *.gif)|*.jpg; *.png; *.gif"
If red.ShowDialog() = DialogResult.OK Then
Dim img As New DataGridViewImageColumn
Dim img1 As Image = Image.FromFile(red.FileName)
img.Image = img1
dg.Rows.Add(t1.Text, t2.Text, t3.Text ts.Text, tt.Text, img1)
End If
Catch ex As Exception
End Try
أشكرك أخي الكريم ولكن هذا الكود للداتاقريد وليس لليست فيو
تحياتي
(07-01-16, 06:53 AM)sami2015 كتب :PHP كود :
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListViewEx1.Columns.Clear()
ListViewEx1.Columns.Add("name", 200)
ListViewEx1.Columns.Add("images", 50)
ListViewEx1.Items.Clear()
ListViewEx1.Items.Add(New ListViewItem(New String() {"منتدى فيجوال بيسك لكل العرب", "http://vb4arb.com/vb/images/MyBBPro/logo.png"}))
ListViewEx1.Items.Add(New ListViewItem(New String() {"العزابي", "http://vb4arb.com/vb/uploads/avatars/avatar_9.jpg?dateline=1379254956"}))
ListViewEx1.Items.Add(New ListViewItem(New String() {"abulayth", "http://vb4arb.com/vb/gallery/153_21_09_13_2_49_26.jpeg?dateline=1379796733"}))
For Each itm As ListViewItem In ListViewEx1.Items
Dim link As New LinkLabel
AddHandler link.LinkClicked, AddressOf LinkLabel_LinkClicked
link.Text = "صورة" ' itm.SubItems(1).Text
ListViewEx1.AddEmbeddedControl(link, ListViewEx1.Columns(1).Index, itm.Index)
Next
ListViewEx1.SelectedItems(0).Selected = True
End Sub
Private Sub LinkLabel_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs)
Process.Start(ListViewEx1.SelectedItems(0).SubItems(1).Text)
'MsgBox(ListViewEx1.SelectedItems(0).SubItems(1).Text)
End Sub
End Class
#Region "ListViewEx"
Public Class ListViewEx
Inherits ListView
#Region "Interop-Defines"
<Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wPar As IntPtr, ByVal lPar As IntPtr) As IntPtr
End Function
' ListView messages
Private Const LVM_FIRST As Integer = &H1000
Private Const LVM_GETCOLUMNORDERARRAY As Integer = (LVM_FIRST + 59)
' Windows Messages
Private Const WM_PAINT As Integer = &HF
#End Region
''' <summary>
''' Structure to hold an embedded control's info
''' </summary>
Private Structure EmbeddedControl
Public Control As Control
Public Column As Integer
Public Row As Integer
Public Dock As DockStyle
Public Item As ListViewItem
End Structure
Private _embeddedControls As New ArrayList()
Public Sub New()
End Sub
''' <summary>
''' Retrieve the order in which columns appear
''' </summary>
''' <returns>Current display order of column indices</returns>
Protected Function GetColumnOrder() As Integer()
Dim lPar As IntPtr = Runtime.InteropServices.Marshal.AllocHGlobal(Runtime.InteropServices.Marshal.SizeOf(GetType(Integer)) * Columns.Count)
Dim res As IntPtr = SendMessage(Handle, LVM_GETCOLUMNORDERARRAY, New IntPtr(Columns.Count), lPar)
If res.ToInt32() = 0 Then
' Something went wrong
Runtime.InteropServices.Marshal.FreeHGlobal(lPar)
Return Nothing
End If
Dim order As Integer() = New Integer(Columns.Count - 1) {}
Runtime.InteropServices.Marshal.Copy(lPar, order, 0, Columns.Count)
Runtime.InteropServices.Marshal.FreeHGlobal(lPar)
Return order
End Function
''' <summary>
''' Retrieve the bounds of a ListViewSubItem
''' </summary>
''' <param name="Item">The Item containing the SubItem</param>
''' <param name="SubItem">Index of the SubItem</param>
''' <returns>Subitem's bounds</returns>
Protected Function GetSubItemBounds(ByVal Item As ListViewItem, ByVal SubItem As Integer) As Rectangle
Dim subItemRect As Rectangle = Rectangle.Empty
If Item Is Nothing Then
Throw New ArgumentNullException("Item")
End If
Dim order As Integer() = GetColumnOrder()
If order Is Nothing Then
' No Columns
Return subItemRect
End If
If SubItem >= order.Length Then
Throw New IndexOutOfRangeException("SubItem " + SubItem + " out of range")
End If
' Retrieve the bounds of the entire ListViewItem (all subitems)
Dim lviBounds As Rectangle = Item.GetBounds(ItemBoundsPortion.Entire)
Dim subItemX As Integer = lviBounds.Left
' Calculate the X position of the SubItem.
' Because the columns can be reordered we have to use Columns[order[i]] instead of Columns[i] !
Dim col As ColumnHeader
Dim i As Integer
For i = 0 To order.Length - 1
col = Me.Columns(order(i))
If col.Index = SubItem Then
Exit For
End If
subItemX += col.Width
Next
subItemRect = New Rectangle(subItemX, lviBounds.Top, Me.Columns(order(i)).Width, lviBounds.Height)
Return subItemRect
End Function
''' <summary>
''' Add a control to the ListView
''' </summary>
''' <param name="c">Control to be added</param>
''' <param name="col">Index of column</param>
''' <param name="row">Index of row</param>
Public Sub AddEmbeddedControl(ByVal c As Control, ByVal col As Integer, ByVal row As Integer)
AddEmbeddedControl(c, col, row, DockStyle.Fill)
End Sub
''' <summary>
''' Add a control to the ListView
''' </summary>
''' <param name="c">Control to be added</param>
''' <param name="col">Index of column</param>
''' <param name="row">Index of row</param>
''' <param name="dock">Location and resize behavior of embedded control</param>
Public Sub AddEmbeddedControl(ByVal c As Control, ByVal col As Integer, ByVal row As Integer, ByVal dock As DockStyle)
If c Is Nothing Then
Throw New ArgumentNullException()
End If
If col >= Columns.Count OrElse row >= Items.Count Then
Throw New ArgumentOutOfRangeException()
End If
Dim ec As EmbeddedControl
ec.Control = c
ec.Column = col
ec.Row = row
ec.Dock = dock
ec.Item = Items(row)
_embeddedControls.Add(ec)
' Add a Click event handler to select the ListView row when an embedded control is clicked
AddHandler c.Click, AddressOf _embeddedControl_Click
Me.Controls.Add(c)
End Sub
''' <summary>
''' Remove a control from the ListView
''' </summary>
''' <param name="c">Control to be removed</param>
Public Sub RemoveEmbeddedControl(ByVal c As Control)
If c Is Nothing Then
Throw New ArgumentNullException()
End If
For i As Integer = 0 To _embeddedControls.Count - 1
Dim ec As EmbeddedControl = CType(_embeddedControls(i), EmbeddedControl)
If ec.Control Is c Then
RemoveHandler c.Click, AddressOf _embeddedControl_Click
Me.Controls.Remove(c)
_embeddedControls.RemoveAt(i)
Return
End If
Next
Throw New Exception("Control not found!")
End Sub
''' <summary>
''' Retrieve the control embedded at a given location
''' </summary>
''' <param name="col">Index of Column</param>
''' <param name="row">Index of Row</param>
''' <returns>Control found at given location or null if none assigned.</returns>
Public Function GetEmbeddedControl(ByVal col As Integer, ByVal row As Integer) As Control
For Each ec As EmbeddedControl In _embeddedControls
If ec.Row = row AndAlso ec.Column = col Then
Return ec.Control
End If
Next
Return Nothing
End Function
<System.ComponentModel.DefaultValue(View.LargeIcon)> _
Public Shadows Property View() As View
Get
Return MyBase.View
End Get
Set(ByVal value As View)
' Embedded controls are rendered only when we're in Details mode
For Each ec As EmbeddedControl In _embeddedControls
ec.Control.Visible = (value = View.Details)
Next
MyBase.View = value
End Set
End Property
Protected Overrides Sub WndProc(ByRef m As Message)
Select Case m.Msg
Case WM_PAINT
If View <> View.Details Then
Exit Select
End If
' Calculate the position of all embedded controls
For Each ec As EmbeddedControl In _embeddedControls
Dim rc As Rectangle = Me.GetSubItemBounds(ec.Item, ec.Column)
If (Me.HeaderStyle <> ColumnHeaderStyle.None) AndAlso (rc.Top < Me.Font.Height) Then
' Control overlaps ColumnHeader
ec.Control.Visible = False
Continue For
Else
ec.Control.Visible = True
End If
Select Case ec.Dock
Case DockStyle.Fill
Exit Select
Case DockStyle.Top
rc.Height = ec.Control.Height
Exit Select
Case DockStyle.Left
rc.Width = ec.Control.Width
Exit Select
Case DockStyle.Bottom
rc.Offset(0, rc.Height - ec.Control.Height)
rc.Height = ec.Control.Height
Exit Select
Case DockStyle.Right
rc.Offset(rc.Width - ec.Control.Width, 0)
rc.Width = ec.Control.Width
Exit Select
Case DockStyle.None
rc.Size = ec.Control.Size
Exit Select
End Select
' Set embedded control's bounds
ec.Control.Bounds = rc
Next
Exit Select
End Select
MyBase.WndProc(m)
End Sub
Private Sub _embeddedControl_Click(ByVal sender As Object, ByVal e As EventArgs)
' When a control is clicked the ListViewItem holding it is selected
For Each ec As EmbeddedControl In _embeddedControls
If ec.Control Is DirectCast(sender, Control) Then
Me.SelectedItems.Clear()
ec.Item.Selected = True
End If
Next
End Sub
End Class
#End Region
شكراً لك أخي الكريم جاري التجربة وإنشالله يحقق مطلبي
أشكرك
تحياتي
