【问题标题】:How to get comboBox for a specific cell in gridControl如何获取gridControl中特定单元格的组合框
【发布时间】:2016-12-17 19:09:00
【问题描述】:

我需要获取特定单元格的组合框。怎么做。我试过了,但我做不到。我不明白我的代码有什么问题。

     if (Convert.ToInt32(ddlModule.SelectedValue) == 5 && _entryType == Constants.EntryType.ENTRY_TYPE_DAILY)
        {
            column = new GridColumn();
            column.Name = "Actual";
            column.Caption = "Actual";
            column.Width = 125;
            column.AllowEdit = true;
            column.Type = GridColumnType.Int32;
            foreach (GridRow row in gridControl.Rows)
            {
                if(GridRow.Rows[i].Cells[2])
                {
                column.Type = GridColumnType.EditableCombo;
                }
            }

            gridControl.AddColumn(column);
        }

【问题讨论】:

    标签: c#-4.0 row cell


    【解决方案1】:

    首先找到当前行。 现在找到行内的控件。 从控件组中查找所需的控件类型。

    GridViewRow row = (GridViewRow)(cont).NamingContainer;
    
    int rowID = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
    
    DropDownList dropdown = (DropDownList)row.Cells[0].FindControl("DropDownList1");
    

    或者

    DataGridViewComboBoxCell dgvcmbcell = dataGridView1[1, 0] as DataGridViewComboBoxCell;
    

    【讨论】:

    • 它不工作。GridRow row = (GridRow)(cont).NamingContainer; int rowID = Convert.ToInt32(gridControl.DataKeys[row.RowIndex].Value); DropDownList dropdown = (DropDownList)row.Cells[0].FindControl("DropDownList1");
    • 我现在还没有IDE,所以我不能给你确切的解决方案,你必须按照黄色块所示一步一步来。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-20
    • 2020-01-28
    • 1970-01-01
    • 1970-01-01
    • 2014-07-21
    相关资源
    最近更新 更多