Image in datatable

后端 未结 2 548
不思量自难忘°
不思量自难忘° 2021-01-23 05:12

I read image by using OpenFileDialog. Sample code is below:

openFileDialog1.ShowDialog();
if (openFileDialog1.FileName != null)
   if (picBoardImage.Image != nul         


        
2条回答
  •  醉话见心
    2021-01-23 05:19

    I was actually trying to accomplish this as well. My solution actually is not that involved.

    Drawing.Bitmap img = new Drawing.Bitmap("Path to image"); //Replace string with your OpenFileDialog path.
    
    DataColumn column = new DataColumn("ImageColumn");
    column.DataType = System.Type.GetType("System.Drawing.Bitmap");
    
    //Code to add data to a cell:
    DataRow row = new DataRow();
    row("ImageColumn") = img;
    

    For me this worked like a charm.

提交回复
热议问题