DataGrid中能不能显示图片?

ghw 2003-08-13 06:40:07
WinForm中的DataGrid能不能在某些cell中显示图片?
...全文
102 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
ghw 2003-08-14
  • 打赏
  • 举报
回复
谢谢, 我试试
greenclass 2003-08-13
  • 打赏
  • 举报
回复
of course can.
the datalist too,
雪狼1234567 2003-08-13
  • 打赏
  • 举报
回复
这儿有例子和源码?
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q1019q

5.81 How can I have a column of bitmaps in a DataGrid?

You can derive a custom columnstyle and override its Paint method to draw the image. Here are both C# and VB.Net samples.

The Paint override offers three ways to draw the bimap in the cell; size it to fit the cell bounds, size it proportionally to fit the cell bounds, and draw it with it's original size (clipping the bitmap to fit in the cell bounds). In the sample, the DataGrid is anchored on all four sides, so as you size the form, the DataGrid sizes as well. The dataGrid1_Resized event is handled to dynamically change the PreferredRowHeight and PreferredColumnWidth so the cells occupy all of the datagrid's client area. So, as you size the form, the grid cells size also so you can easily see the bitmaps.

ghw 2003-08-13
  • 打赏
  • 举报
回复
怎么写啊
wjohenw 2003-08-13
  • 打赏
  • 举报
回复
自己重新写一个component就可以了
ghw 2003-08-13
  • 打赏
  • 举报
回复
to 楼上:

我想知道WinForm中的DataGrid可不可以
panyee 2003-08-13
  • 打赏
  • 举报
回复
showimg.aspx?id=xxx

在此页面中, 专门根据id来
Response.ContentType = "image/jpeg";
Response.BinaryWrite(byte[]);//byte[]为图象数据
Response.End();
输出图片
panyee 2003-08-13
  • 打赏
  • 举报
回复
<asp:TemplateColumn HeaderText="图片">
<HeaderStyle Width="40"></HeaderStyle>
<ItemTemplate>
<img src="showimg.aspx?id=<%# DataBinder.Eval(Container.DataItem, "ID")%>" border=0>
</ItemTemplate>

</asp:TemplateColumn>

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧