Guest User

Untitled

a guest
May 25th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. DTable = new DataTable();
  2. SBind = new BindingSource();
  3. //ServersTable - DataGridView
  4. for (int i = 0; i < ServersTable.ColumnCount; ++i)
  5. {
  6. DTable.Columns.Add(new DataColumn(ServersTable.Columns[i].Name));
  7. }
  8.  
  9. for (int i = 0; i < Apps.Count; ++i)
  10. {
  11. DataRow r = DTable.NewRow();
  12. r.BeginEdit();
  13. foreach (DataColumn c in DTable.Columns)
  14. {
  15. r[c.ColumnName] = //writing values
  16. }
  17. r.EndEdit();
  18. DTable.Rows.Add(r);
  19. }
  20. SBind.DataSource = DTable;
  21. ServersTable.DataSource = SBind;
  22.  
  23. ServersTable.Columns.Clear();
  24. ServersTable.DataSource = SBind;
  25.  
  26. for (int i = 0; i < ServersTable.ColumnCount; ++i) {
  27. DTable.Columns.Add(new DataColumn(ServersTable.Columns[i].Name));
  28. ServersTable.Columns[i].DataPropertyName = ServersTable.Columns[i].Name;
  29. }
  30.  
  31. DataTable DTable = new DataTable();
  32. BindingSource SBind = new BindingSource();
  33. SBind.DataSource = DTable;
  34. DataGridView ServersTable = new DataGridView();
  35.  
  36. ServersTable.AutoGenerateColumns = false;
  37. ServersTable.DataSource = DTable;
  38.  
  39. ServersTable.DataSource = SBind;
  40. ServersTable.Refresh();
  41.  
  42. foreach (DictionaryEntry entry in Hashtable)
  43. {
  44. datagridviewTZ.Rows.Add(entry.Key.ToString(), entry.Value.ToString());
  45. }
  46.  
  47. BindingSource SBind = new BindingSource();
  48. SBind.DataSource = dtSourceData;
  49.  
  50. ADGView1.AutoGenerateColumns = true; //must be "true" here
  51. ADGView1.DataSource = dtSourceData;
  52. ADGView1.Columns.Clear();
  53. ADGView1.DataSource = SBind;
  54.  
  55. //set DGV's column names and headings from the Datatable properties
  56. for (int i = 0; i < ADGView1.Columns.Count; i++)
  57. {
  58. ADGView1.Columns[i].DataPropertyName = dtSourceData.Columns[i].ColumnName;
  59. ADGView1.Columns[i].HeaderText = dtSourceData.Columns[i].Caption;
  60. }
  61. ADGView1.Enabled = true;
  62. ADGView1.Refresh();
Add Comment
Please, Sign In to add comment