UltraGrid单元格放多个图片
来源:互联网 发布:淘宝访客突然少了很多 编辑:程序博客网 时间:2024/06/07 03:10
private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e){ // Get the images that we might want to show in the cell. // You could optimize this method by caching the Bitmaps as members of the class. using( Bitmap bmp1 = new Bitmap( @"..\..\squiggle_up.bmp" ) ) using( Bitmap bmp2 = new Bitmap( @"..\..\arrow_up.bmp" ) ) using( Bitmap bmp3 = new Bitmap( @"..\..\squiggle_down.bmp" ) ) using( Bitmap bmp4 = new Bitmap( @"..\..\arrow_down.bmp" ) ) { Bitmap[] bmps; // Using whatever conditions you need, populate the array of Bitmaps // with the appropriate images. For this simple demo, we determine // the images to use based on the customer ID field. int custID = (int)e.Row.Cells[ "custID" ].Value; if( custID < 1 ) bmps = new Bitmap[]{}; else if( custID == 1 ) bmps = new Bitmap[]{ bmp1 }; else if( custID == 2 ) bmps = new Bitmap[]{ bmp1, bmp2 }; else if( custID == 3 ) bmps = new Bitmap[]{ bmp1, bmp2, bmp3 }; else bmps = new Bitmap[]{ bmp1, bmp2, bmp3, bmp4 }; // If we have already given this cell a Bitmap, dispose of it before reassigning the new Bitmap. if( e.ReInitialize ) ((Bitmap)e.Row.Cells["images"].Value).Dispose(); // Pass the array of Bitmaps into the helper method which will // combine all of the images into one. Then assign that new image // to the value of the cell. e.Row.Cells["images"].Value = CombineBitmaps( bmps ); }}
private Bitmap CombineBitmaps( Bitmap[] bitmaps ){ if( bitmaps.Length == 0) return new Bitmap( 1, 1 ); int width = 0; int height = 0; foreach( Bitmap bmp in bitmaps ) { width += bmp.Width; if( height < bmp.Height ) height = bmp.Height; } Bitmap bitmap = new Bitmap( width, height ); using( Graphics grfx = Graphics.FromImage( bitmap ) ) { int x = 0; foreach( Bitmap bmp in bitmaps ) { grfx.DrawImage( bmp, x, 0, bmp.Width, height ); x += bmp.Width; } } return bitmap;}
0 0
- UltraGrid单元格放多个图片
- ultraGrid 定制单元格合并逻辑
- ultraGrid的单元格怎么自动换行
- UltraGrid
- UltraGrid
- UltraGrid的使用(二):单元格输入内容的验证
- 上下左右键控制ultraGrid单元格数据的移动
- 如何实现UltraGrid中的图片按钮效果
- 引用单元格的图片
- 关于单元格插入图片
- 报表单元格图片构件
- [WinForm每日一贴] 如何实现UltraGrid中的图片按钮效果
- 单元格变色和图片透明
- EXTJS panel单元格添加图片
- AdvStringGrid 单元格动态添加图片
- Excel 单元格中插入图片
- jxl操作excel 单元格样式,合并单元格,插入图片,超链接
- jxl操作excel 单元格样式,合并单元格,插入图片,超链接
- Linq学习__05__查询表达式和方法查询比较
- Vector介绍
- 建个技术博客迫在眉睫
- C++ arraylist实现
- 分析kernel的initcall函数
- UltraGrid单元格放多个图片
- sicily Check if a binary tree satisfies the binary search tree property
- hdu 1142 记忆化搜索
- ADF学习笔记(一)
- Hadoop作业提交跟踪
- Redhat修改主机名及网络配置
- prophecy about automotive tech
- MySQL 添加列,修改列,删除列
- sicily 1561.PRIME