datagridview dynamic with image

前端 未结 2 1387
北荒
北荒 2021-01-26 14:33

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

2条回答
  •  广开言路
    2021-01-26 15:01

      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();
    }
    

提交回复
热议问题