05-12-22, 10:35 PM
(05-12-22, 04:02 PM)احمد كبه كتب : شكرا جزيلا استاذي العزيز لكن لا تزال هناك مشكلة و هيجرب ما يلي بذات المثال
System.InvalidOperationException
HResult=0x80131509
Message=Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound.
Source=System.Windows.Forms
PHP كود :
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
For Each file As String In Directory.GetFiles(Path, "*.pdf*")
DataGridView1.Rows.Add(file)
Next
Catch ex As Exception
End Try
End Sub
و اما اذا كانت عكس ذلك اي تحوي عدة اعمدة و كمثال آخر و اعتبارا انها ذات 3 اعمدة مثلا يمكنك تعبئتها كما يلي
PHP كود :
For Each file As String In Directory.GetFiles(Path, "*.pdf*")
Dim row As String() = New String() {"", file, ""}
DataGridView1.Rows.Add(row)
Next

