【问题标题】:DataTable with a dropdown Column at the endDataTable 末尾有一个下拉列
【发布时间】:2021-11-14 19:46:17
【问题描述】:

我已经有一个 DataTable (dt)。现在我想在表格末尾有一列,我可以在其中使用下拉菜单选择不同的数字。我只是找不到可以做到这一点的函数。

DataTable dt = new DataTable();// neuer DataTable dt wird erzeugt

foreach (IXLCell cell in row.Cells())
{                                   
  dt.Columns.Add(cell.Value.ToString());
}
if (dt.Columns.Count > 5) //prüfen ob Datum Kürzel und OK schon vorhanden sind 
{
  dt.Columns.Add(new DataColumn("CODE", typeof(string))); 
  // here i want to add the DropDown Menu Column
  //Code is "ONE" or "TWO"
}
else //falss nicht --> hinzufügen
{
  dt.Columns.Add(new DataColumn("OK", typeof(bool)));
  dt.Columns.Add(new DataColumn("Datum", typeof(string)));
  dt.Columns.Add(new DataColumn("Kürzel", typeof(string)));
}

【问题讨论】:

    标签: c# windows forms windows-forms-designer


    【解决方案1】:

    只需添加一个数字字段 (int) 或字符串,无论哪个更适合您的数据。不是数据表本身的问题,后面怎么显示。您可以显示表格,例如使用 DataGridView,您可以将列类型选择为带有组合框的列。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-10
      • 2019-04-07
      相关资源
      最近更新 更多