这个我的效果,但是每个菜单的价格列表变成都一样,数据库中的字段有些是一个价格,有些是多个价格组合起来的(如7,8,9)这是后台的代码
private void ShowData(List<MFood> modelList)
{
dataFoodList.Rows.Clear();
DataGridViewComboBoxColumn DgvCell = (DataGridViewComboBoxColumn)dataFoodList.Columns["dvPrice"];
foreach (var model in modelList)
{
string[] reg = model.Price.Split(',');
// //DataGridViewComboBoxCell DgvCell = dataFoodList.Rows[dataFoodList.Rows.Count].Cells["dvPrice"] as DataGridViewComboBoxCell;
// DgvCell.Items.AddRange(reg);
dataFoodList.SetDataGridViewColumns(model, -1, "dvIsEnable,dvCreateDatetime,dvUpdateDatetime,dvPrice");
dataFoodList.Rows[dataFoodList.Rows.Count - 1].Cells["dvCreateDatetime"].Value = model.CreateDatetime.Date.ToString("yyyy-MM-dd");
dataFoodList.Rows[dataFoodList.Rows.Count - 1].Cells["dvUpdateDatetime"].Value = model.UpdateDatetime.ToString("yyyy-MM-dd");
if (reg != null)
{
foreach (var price in reg)
{
//dataFoodList.Rows[dataFoodList.Rows.Count - 1].Cells["dvPrice"].Value = price;
DgvCell.Items.AddRange(price);
}
}
if (model.IsEnable == 1)
dataFoodList.Rows[dataFoodList.Rows.Count - 1].Cells["dvIsEnable"].Value = "有效";
if (model.IsEnable == 0)
dataFoodList.Rows[dataFoodList.Rows.Count - 1].Cells["dvIsEnable"].Value = "无效";
}
}太久没有弄博客了,没多少豆子,请高手给一下经验,不甚感激
这样看应该清楚点