SHARE
TWEET

Untitled

a guest Jan 18th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string[][] jagged = new string [100][];
  2.  
  3. //...jagged array is populated...
  4.  
  5. dataGridView1.DataSource = jagged;
  6.    
  7. //
  8. // 1. Create two dimensional array
  9. //
  10.  
  11. const int  dim = 1000;
  12.  
  13. double[,]  array = new double[dim,dim];
  14.  
  15. Random ran = new Random();
  16. for(int r = 0; r < dim; r++)
  17. {
  18.     for(int c = 0; c < dim; c++)
  19.     {
  20.         array[r,c] = (ran.Next(dim)); // fill it with random numbers.
  21.     }
  22. }
  23.  
  24. // 2. Create ArrayDataView class in which
  25. // constructor you pass the array
  26. // and assign it to DataSource property of DataGrid.
  27.  
  28.  dataGrid1.DataSource = new ArrayDataView(array);
  29.    
  30. string[][] arr = new string[2][];
  31.  
  32. arr[0] = new String[] {"a","b"};
  33. arr[1] = new String[] {"c","d"};
  34.  
  35. DataGrid1.DataSource = arr[0];
  36. DataGrid1.DataBind();//The result is: a,b in datagrid
  37.    
  38. List<string> names = new List<string>(new string[]
  39. {
  40.     "John",
  41.     "Frank",
  42.     "Bob"
  43. });
  44.  
  45. var bindableNames =
  46.     from name in names
  47.     select new {Names=name};
  48.  
  49. dataGridView1.DataSource = bindableNames.ToList();
  50.    
  51. string[][] stringRepresentation = ds.Tables[0].Rows  
  52.     .OfType<DataRow>()  
  53.     .Select(r => ds.Tables[0].Columns  
  54.         .OfType<DataColumn>()  
  55.         .Select(c => r[c.ColumnName].ToString())  
  56.         .ToArray())  
  57.     .ToArray();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top