datagridview的动态与形象 [英] datagridview dynamic with image

查看:181
本文介绍了datagridview的动态与形象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助来动态地创建一个DataGridView。

我们的目标是ping通的IP或主机名成功的一个列表,并插入到网格(主机,日期和图像(红色或绿色)),这取决于响应。

我有这个功能写入网格,但我有一个问题,如果一个ping命令不成功,他把所有其他与Redball。

继承人的code我使用 HTTP://$c$cpaste.net/yq1pu9

解决方案

 私人无效TabelaDinamimcaSucess(布尔Sucesso的,INT指数,主机串,串数据,串节奏,串状态)
{

   字符串[]行=新的String [] {index.ToString(),主机,数据,速度,状态};
   dataGridView1.Rows.Add(行);

    INT NUMBER_OF_ROWS = dataGridView1.RowCount -1;

    位图B =新位图((Sucesso的==真Properties.Resources.greenBall:Properties.Resources.redBall));
    图标图标= Icon.FromHandle(b.GetHicon());

    。dataGridView1.Rows [NUMBER_OF_ROWS] .Cells [IMG]值=图标;

    dataGridView1.Show();
}
 

I need a little help to create a datagridview dynamically.

The objective is to ping a list of IP or HostName's success and inserted in the grid (host, date, and Image (Red or Green)) depending on response.

I have this function that writes the grid, but I have a problem if one ping is not successful he puts all others with Redball.

Heres the code i'm using http://codepaste.net/yq1pu9

解决方案

  private void TabelaDinamimcaSucess(bool sucesso, int index, string host, string data, string tempo,string status)
{

   string[] row = new string[] { index.ToString(), host, data, tempo,status };
   dataGridView1.Rows.Add(row);

    int number_of_rows = dataGridView1.RowCount -1;

    Bitmap b = new Bitmap((sucesso == true ? Properties.Resources.greenBall : Properties.Resources.redBall));
    Icon icon = Icon.FromHandle(b.GetHicon());

    dataGridView1.Rows[number_of_rows].Cells["img"].Value = icon;

    dataGridView1.Show();
}

这篇关于datagridview的动态与形象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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