Tell me how in this example to decode the second column (content) from base64 and display both columns in the datagridview?

System.IO.StreamReader sr = new System.IO.StreamReader(openFileDialog1.FileName); sr.Close(); string filename = openFileDialog1.FileName; string sql = "SELECT datetime(datetime_int,'unixepoch'), content FROM sms"; var conn = new SQLiteConnection("Data Source=" + filename + ";Version=3;"); conn.Open(); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, conn); da.Fill(ds); dataGridView1.DataSource = ds.Tables[0].DefaultView; 
  • If this is not what you need, then please clarify the question - user227049
  • The problem is that after the sql query, the columns for the datagridview are automatically generated. How to handle a column (in the example it is 'content') with base64-encrypted content and decode it, for example, in utf-8? - Yuri

1 answer 1

If this is still relevant for you, then here is the starting point, starting from which you will solve your problem:

  1. Add a new column to your dtGridView by the form designer, let's say at the position (column sequence number) decodeContentNum ;

  2. On the event RowValidating for dtGridView hang code:

     private void dtGridView_RowValidating(object sender, DataGridViewCellCancelEventArgs e) { int rowIndex = e.RowIndex; DataGridViewRow viewRow = dtGridView.Rows[rowIndex]; DataRowView rw = (DataRowView) viewRow.DataBoundItem; if (rw != null) { DataRow row = rw.Row; if (row != null) { dtGridView[decodeContentNum, rowIndex].Value = MyDecode(row["content"]); //Здесь Ваши преобразования } } } 

where MyDecode your decoding function.

This is just a scheme for solving your problem, to which you need to make your own efforts. I hope that she will help you.