在绑定到数据源的基础设施Ultrawingrid中添加一个复选框列 [英] Adding a checkbox column to the infragistics ultrawingrid that is bind to a datasource

查看:160
本文介绍了在绑定到数据源的基础设施Ultrawingrid中添加一个复选框列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将新的复选框列添加到绑定到数据集的ultrawingrid中,每当我添加新列时,都会显示未找到密钥,有关如​​何解决它的任何想法,谢谢...

下面是代码

private void grdPayVis_InitializeLayout(object sender, InitializeLayoutEventArgs e)
{

    var gridBand = grdPayVis.DisplayLayout.Bands[0];

    gridBand.Columns["Select"].Header.Caption = "Select";
    gridBand.Columns["Select"].Header.Appearance.TextHAlign = HAlign.Center;
    gridBand.Columns["Select"].Header.VisiblePosition = 0;
    gridBand.Columns["Select"].Hidden = false;
    gridBand.Columns["Select"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox;
    gridBand.Columns["Select"].AutoSizeMode = ColumnAutoSizeMode.AllRowsInBand;
    gridBand.Columns["Select"].CellActivation = Activation.AllowEdit;
    gridBand.Columns["Select"].CellAppearance.TextHAlign = HAlign.Center;
    gridBand.Columns["Select"].CellClickAction = CellClickAction.Edit;

}

Swetha

解决方案

当网格的数据源设置为数据表或其他绑定源时,它将自动创建数据表或数据源属性中存在的列.如果您想再创建一列,则需要先添加它,然后再尝试从Band列中引用它

private void grdPayVis_InitializeLayout(object sender, InitializeLayoutEventArgs e) 
{
    var gridBand = grdPayVis.DisplayLayout.Bands[0]; 

    // Check if the column exists, if not, add it
    if(!gridBand.Columns.Exists("Select"))
        gridBand.Columns.Add("Select", "Select");


    // Not needed, the ADD adds the Key and the Caption
    // gridBand.Columns["Select"].Header.Caption = "Select"; 

    // Now you can reference the column with the Key = "Select"
    gridBand.Columns["Select"].Header.VisiblePosition = 0; 
    gridBand.Columns["Select"].Hidden = false; 
    gridBand.Columns["Select"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox; 
    gridBand.Columns["Select"].AutoSizeMode = ColumnAutoSizeMode.AllRowsInBand; 
    gridBand.Columns["Select"].CellClickAction = CellClickAction.Edit; 
} 

I am trying to add a new checkbox column to the ultrawingrid that is binding to a dataset, when ever I add a new column it says key not found, any ideas on how to fix it, Thank you...

Below is the code

private void grdPayVis_InitializeLayout(object sender, InitializeLayoutEventArgs e)
{

    var gridBand = grdPayVis.DisplayLayout.Bands[0];

    gridBand.Columns["Select"].Header.Caption = "Select";
    gridBand.Columns["Select"].Header.Appearance.TextHAlign = HAlign.Center;
    gridBand.Columns["Select"].Header.VisiblePosition = 0;
    gridBand.Columns["Select"].Hidden = false;
    gridBand.Columns["Select"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox;
    gridBand.Columns["Select"].AutoSizeMode = ColumnAutoSizeMode.AllRowsInBand;
    gridBand.Columns["Select"].CellActivation = Activation.AllowEdit;
    gridBand.Columns["Select"].CellAppearance.TextHAlign = HAlign.Center;
    gridBand.Columns["Select"].CellClickAction = CellClickAction.Edit;

}

Swetha

解决方案

When the grid has its datasource set to a datatable or other binding source, it automatically creates the columns present in the datatable or in the properties of the datasource. If you want to have another column you need to ADD it before trying to reference it from the Band columns

private void grdPayVis_InitializeLayout(object sender, InitializeLayoutEventArgs e) 
{
    var gridBand = grdPayVis.DisplayLayout.Bands[0]; 

    // Check if the column exists, if not, add it
    if(!gridBand.Columns.Exists("Select"))
        gridBand.Columns.Add("Select", "Select");


    // Not needed, the ADD adds the Key and the Caption
    // gridBand.Columns["Select"].Header.Caption = "Select"; 

    // Now you can reference the column with the Key = "Select"
    gridBand.Columns["Select"].Header.VisiblePosition = 0; 
    gridBand.Columns["Select"].Hidden = false; 
    gridBand.Columns["Select"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox; 
    gridBand.Columns["Select"].AutoSizeMode = ColumnAutoSizeMode.AllRowsInBand; 
    gridBand.Columns["Select"].CellClickAction = CellClickAction.Edit; 
} 

这篇关于在绑定到数据源的基础设施Ultrawingrid中添加一个复选框列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆