18-03-13, 02:02 PM
اول مرة اكون عاجز عن الشكر او حتي الثناء عموما انا الموضوع مكنتش بفكر فية ولكن بعد الرابط دة اتغير تفكيري
http://stackoverflow.com/questions/14476...dview-cell
وانا اريد التعديد علي اكوادي لوضع 3 صور في حالة الاضافة
وانا من المثال السابق هقدر اعرض 3 صور بس مش عارف هحفظ اذاي انا باستخدم الكود دة لصورة واحدة اذاي اخلية ل3 صور وممكن اعمل مسافة ولو صغيرة بين كل صورة واخريlog
Try
If PictureBox1.Image IsNot Nothing Then
If MsgBox(" هل تريد استبدال الصورة الحالية " & " ؟ ", MsgBoxStyle.Exclamation + MsgBoxStyle.MsgBoxRight + MsgBoxStyle.OkCancel, "استبدال صورة") = MsgBoxResult.Cancel Then Exit Sub
Else
If MsgBox(" استمرار اضافة صورة جديدة للسجل رقم " & Label2.Text & " ؟ ", MsgBoxStyle.Exclamation + MsgBoxStyle.MsgBoxRight + MsgBoxStyle.OkCancel, "ادراج صورة") = MsgBoxResult.Cancel Then Exit Sub
End If
Application.DoEvents()
Dim OFG As New OpenFileDia
OFG.Filter = "Files(*.jpg)|*.jpg|Files(*.gif)|*.gif|Files(*.bmp)|*.bmp|Files(*.png)|*.png"
OFG.Title = "ادراج صورة"
OFG.FileName = ""
If OFG.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim fs As IO.FileStream = New IO.FileStream(OFG.FileName, IO.FileMode.Open, IO.FileAccess.Read)
Dim LoadImage As Image = Image.FromStream(fs)
fs.Close()
Dim Stream As New IO.MemoryStream()
Dim NewBitmap As New Bitmap(LoadImage, 200, 225)
NewBitmap.Save(Stream, System.Drawing.Imaging.ImageFormat.Jpeg)
Application.DoEvents()
BindingSource1.EndEdit()
DataAdapter1.Update(DataSet1.Tables("Tb1"))
DataSet1.Tables("Tb1").Rows(BindingSource1.Position).Item("Pic") = Stream.ToArray
Stream.Close()
BindingSource1.EndEdit()
DataAdapter1.Update(DataSet1.Tables("Tb1"))
Application.DoEvents()
MsgBox("تم حفظ الصورة نجاح", MsgBoxStyle.MsgBoxRight + MsgBoxStyle.Information, "نجاح ")
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
http://stackoverflow.com/questions/14476...dview-cell
وانا اريد التعديد علي اكوادي لوضع 3 صور في حالة الاضافة
وانا من المثال السابق هقدر اعرض 3 صور بس مش عارف هحفظ اذاي انا باستخدم الكود دة لصورة واحدة اذاي اخلية ل3 صور وممكن اعمل مسافة ولو صغيرة بين كل صورة واخريlog
Try
If PictureBox1.Image IsNot Nothing Then
If MsgBox(" هل تريد استبدال الصورة الحالية " & " ؟ ", MsgBoxStyle.Exclamation + MsgBoxStyle.MsgBoxRight + MsgBoxStyle.OkCancel, "استبدال صورة") = MsgBoxResult.Cancel Then Exit Sub
Else
If MsgBox(" استمرار اضافة صورة جديدة للسجل رقم " & Label2.Text & " ؟ ", MsgBoxStyle.Exclamation + MsgBoxStyle.MsgBoxRight + MsgBoxStyle.OkCancel, "ادراج صورة") = MsgBoxResult.Cancel Then Exit Sub
End If
Application.DoEvents()
Dim OFG As New OpenFileDia
OFG.Filter = "Files(*.jpg)|*.jpg|Files(*.gif)|*.gif|Files(*.bmp)|*.bmp|Files(*.png)|*.png"
OFG.Title = "ادراج صورة"
OFG.FileName = ""
If OFG.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim fs As IO.FileStream = New IO.FileStream(OFG.FileName, IO.FileMode.Open, IO.FileAccess.Read)
Dim LoadImage As Image = Image.FromStream(fs)
fs.Close()
Dim Stream As New IO.MemoryStream()
Dim NewBitmap As New Bitmap(LoadImage, 200, 225)
NewBitmap.Save(Stream, System.Drawing.Imaging.ImageFormat.Jpeg)
Application.DoEvents()
BindingSource1.EndEdit()
DataAdapter1.Update(DataSet1.Tables("Tb1"))
DataSet1.Tables("Tb1").Rows(BindingSource1.Position).Item("Pic") = Stream.ToArray
Stream.Close()
BindingSource1.EndEdit()
DataAdapter1.Update(DataSet1.Tables("Tb1"))
Application.DoEvents()
MsgBox("تم حفظ الصورة نجاح", MsgBoxStyle.MsgBoxRight + MsgBoxStyle.Information, "نجاح ")
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
