0
我正在開發WPF中的應用程序,並且該應用程序的一部分涉及提取和合並數據frfom三個excel工作表並顯示在datagrid中。現在,如果datagrid中的一行具有與多個應用程序相對應的隊列,則它將顯示一個組合框,通過在該Excel工作表中查找相應的隊列名稱,該組合框的項目將從另一個Excel表中拉出。在WPF中動態添加組合框在Datagrid細胞中
我以前使用ASP.NET相同的功能,並取得了相當容易,使用下面的代碼:
for (int i = 0; i < dt.Rows.Count; i++)
{
//Filling datatable dsq from excel sheet
//dsq contains the data where it is found out how many applications are there for
//ith row in Gridview
count[i] = dsq.Tables[0].Rows.Count;
foreach (GridViewRow row in gvApplications.Rows)
{
// Transferring gridview rows to a datatable
if (row.Cells[0].Text.Trim().Equals(dt.Rows[i][0].ToString().Trim()))
{
//Dropdownlist is added only when no. of applications for each queue , i.e. ,
/count[i] is greater than 1 , else level control is added.
if (count[i] > 1)
{
DropDownList drp = new DropDownList();
drp.DataSource = dsq.Tables[0];
drp.DataTextField = "Application Name";
drp.DataValueField = "Application Name";
drp.DataBind();
row.Cells[7].Controls.Add(drp);
}
}
else
{
Label l = new Label();
l.Text = dsq.Tables[0].Rows[0][0].ToString().Trim();
l.ID = "label" + row.RowIndex.ToString();
row.Cells[7].Controls.Add(l);
}
}
現在我想在WPF相同的功能。請幫助我。