在telerik radgrindview(winform)中将列表绑定到GridviewCombobox列

时间:2016-02-03 14:12:39

标签: telerik bind radgridview

我有一个像

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

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

我将返回列表绑定到telerik radgridview。

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

我在radgridview_complete_binding之后将优惠券列表绑定到组合框。

2 个答案:

答案 0 :(得分:0)

  1. 您需要使用列和数据创建网格
  2. 您需要添加组合框列,对其进行初始化..请检查您是否需要在此处设置数据编辑器
  3. 将字符串分配给datasource

    comboColumn.DataSource = new String [] {&#34; Test1&#34;,&#34; Test2&#34;};

  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);
    

答案 1 :(得分:0)

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

例如:

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);