【问题标题】:Bind List to GridviewComboboxcolumn in telerik radgrindview (winform)在telerik radgrindview(winform)中将列表绑定到GridviewComboboxcolumn
【发布时间】:2016-02-03 14:12:38
【问题描述】:

我有一个像

这样的通用列表
List<return> returnlist 

class return
{
  public string returnid {get; set;
  ...
  public List<string> Vouchernumbers
}

我将退货列表绑定到 Telerik radgridview。

如何将凭证列表绑定到每一行的 GridviewCombobox 列?

我已在 radgridview_complete_binding 之后将凭证列表绑定到组合框。

【问题讨论】:

    标签: telerik bind radgridview


    【解决方案1】:
    1. 您需要创建包含列和数据的网格
    2. 您需要添加组合框列,对其进行初始化。请检查您是否需要在此处有一个数据编辑器
    3. 将字符串分配给数据源

      comboColumn.DataSource = new String[] { "Test1", "Test2"};

    4. 你也可以绑定集合:

      Binding list BindingList<ComboBoxDataSourceObject>  list                                      = new BindingList<ComboBoxDataSourceObject>();
      ComboBoxDataSourceObject object1 = new ComboBoxDataSourceObject();
      object1.Id = 1;
      object1.MyString = "Test 1";
      list.Add(object1);
      
      ComboBoxDataSourceObject object2 = new ComboBoxDataSourceObject();
      object2.Id = 2;
      object2.MyString = "Test 2";
      list.Add(object2);
      
      colboCol2.DataSource = list;
      radGridView1.Columns.Add(colboCol2);
      

    【讨论】:

    • 这不是问题。我想为 radgrid 中的每一行绑定凭证列表。我在 radgrid_binding_complete 之后绑定了凭证列表,但该列什么也没显示。
    【解决方案2】:

    创建 radcombobox 并设置数据源并将其添加到 rad 网格

    例如:

    GridViewComboBoxColumn col = new GridViewComboBoxColumn();
    col.DataSource = DAL.ActiveDb.GetList<SalesRep>().ToList().OrderBy(x => x.RepName).Select(x => new { Id = x.Id, x.RepName });
    col.DropDownStyle = RadDropDownStyle.DropDown;
    col.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
    
    col.DisplayMember = "RepName";
    col.ValueMember = "Id";
    col.FieldName = "RepId";
    col.HeaderText = "Rep Name";
    col.Width = 200;
    //var t = gridColInfo.Where(x => x.ColumnName.ToLower() == "repid").FirstOrDefault();
    //if (t != null)
    //{
    //    col.Width = t.ColumnWidth;
    //}
    this.radGridBillwiseOpening.Columns.Add(col);
    

    【讨论】:

    • 为什么这有帮助?你能解释一下你的答案吗?
    猜你喜欢
    • 2014-07-12
    • 2021-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多