使DATATABLE中动态插入图片并在DATAGIRDVIEW显示的步骤
PrivateFunctionlabelupdate()AsBoolean
Try
DimiAsInt32
DimaaAsString
aa=""
DataGridView2.AutoGenerateColumns=True
Dimaaa1,aaa2AsImage
aaa1=Global.KITATAMA.My.Resources.Resources.right
aaa2=Global.KITATAMA.My.Resources.Resources.left
Dimms1,ms2AsNewIO.MemoryStream
aaa1.Save(ms1,System.Drawing.Imaging.ImageFormat.Gif)
aaa2.Save(ms2,System.Drawing.Imaging.ImageFormat.Gif)
Dimbuf1,buf2AsSystem.Byte()
''byte[]buf=ms.ToArray();
''ms1.WriteByte(buf1)
buf1=ms1.ToArray
buf2=ms2.ToArray
'MsgBox(buf1.ToString)
''ms2.WriteByte(buf2)
DimiAsInteger
'public_dsListData.Tables(0).Columns.Add("image123",GetType(System.Byte()))
DimnewRowAsDataRow
Dimdatatable2AsNewDataTable
datatable2.Columns.Add("image123",GetType(System.Byte()))
Fori=1Topublic_dsListData.Tables(0).Rows.Count-1
newRow=datatable2.NewRow
datatable2.NewRow()
ms1.Flush()
IfiMod2=0Then
newRow("image123")=ms1.GetBuffer()
Else
newRow("image123")=ms2.GetBuffer()
EndIf
datatable2.Rows.Add(newRow)
Next
WithDataGridView2
.AutoGenerateColumns=False
.DataSource=public_dsListData.Tables(0)
EndWith
ReturnTrue
CatchexAsException
ReturnFalse
EndTry
EndFunction
Try
DimiAsInt32
DimaaAsString
aa=""
DataGridView2.AutoGenerateColumns=True
Dimaaa1,aaa2AsImage
aaa1=Global.KITATAMA.My.Resources.Resources.right
aaa2=Global.KITATAMA.My.Resources.Resources.left
Dimms1,ms2AsNewIO.MemoryStream
aaa1.Save(ms1,System.Drawing.Imaging.ImageFormat.Gif)
aaa2.Save(ms2,System.Drawing.Imaging.ImageFormat.Gif)
Dimbuf1,buf2AsSystem.Byte()
''byte[]buf=ms.ToArray();
''ms1.WriteByte(buf1)
buf1=ms1.ToArray
buf2=ms2.ToArray
'MsgBox(buf1.ToString)
''ms2.WriteByte(buf2)
DimiAsInteger
'public_dsListData.Tables(0).Columns.Add("image123",GetType(System.Byte()))
DimnewRowAsDataRow
Dimdatatable2AsNewDataTable
datatable2.Columns.Add("image123",GetType(System.Byte()))
Fori=1Topublic_dsListData.Tables(0).Rows.Count-1
newRow=datatable2.NewRow
datatable2.NewRow()
ms1.Flush()
IfiMod2=0Then
newRow("image123")=ms1.GetBuffer()
Else
newRow("image123")=ms2.GetBuffer()
EndIf
datatable2.Rows.Add(newRow)
Next
WithDataGridView2
.AutoGenerateColumns=False
.DataSource=public_dsListData.Tables(0)
EndWith
ReturnTrue
CatchexAsException
ReturnFalse
EndTry
EndFunction
本文地址:http://www.45fan.com/dnjc/67400.html