如何动态绘制gridview中的单元格 [英] how to paint cells in gridview in dynamically

查看:61
本文介绍了如何动态绘制gridview中的单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i希望在银行中显示代币...... TokenNo,工作站ID ...我想让闪烁落到我的行或绘画到最顶部的单元格...





提前感谢

解决方案

< blockquote>使用gridview的rowdatabound事件,你可以为所需的单元格或行提供颜色


  void  radGridView1_CellPaint( object  sender,Telerik.WinControls.UI.GridViewCellPaintEventArgs e)
{
GridDataCellElement dataCell = e.Cell as GridDataCellElement;

if (dataCell!= null && dataCell.ColumnInfo。名称== UnitPrice
{
double value = Convert.ToDouble(dataCell.Value);
if value == 0
{
return ;
}

画笔笔刷= < 20 ? Brushes.Red:Brushes.Green;
Size cellSize = e.Cell.Size;

使用(Font font = new 字体( Segoe UI 17 ))
{
e.Graphics.DrawString( *,font,brush,Point.Empty);
}
}
}


hi,

i want to display Tokens like in a Bank ....TokenNo,station id...i want to give flickering fell to my rows or painting to Top most cell...


thanks in advance

解决方案

use rowdatabound event of gridview and u can give colours to required cells or rows


void radGridView1_CellPaint(object sender, Telerik.WinControls.UI.GridViewCellPaintEventArgs e)
{
    GridDataCellElement dataCell = e.Cell as GridDataCellElement;

    if (dataCell != null && dataCell.ColumnInfo.Name == "UnitPrice")
    {
        double value = Convert.ToDouble(dataCell.Value);
        if (value == 0)
        {
            return;
        }

        Brush brush = value < 20 ? Brushes.Red : Brushes.Green;
        Size cellSize = e.Cell.Size;

        using (Font font = new Font("Segoe UI", 17))
        {
            e.Graphics.DrawString("*", font, brush, Point.Empty);
        }
    }
}


这篇关于如何动态绘制gridview中的单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆