我需要一些帮助来动态地创建一个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();
}