1

我有两个 UltraCombo 项目,我试图在表单加载期间设置选定的索引,它们绑定到 UltraGrid EditorComponent,就像这样......

With grdUserAccounts.DisplayLayout.Bands(0)    
    For x = 0 To .Columns.Count - 1
        Select Case .Columns(x).Key
            Case accountCategoryId
                .Columns(x).Header.Caption = "Category"
                .Columns(x).Width = 90
                .Columns(x).Header.Appearance.TextHAlign = Infragistics.Win.HAlign.Center
                .Columns(x).Header.VisiblePosition = 0
                .Columns(x).CellActivation = Activation.AllowEdit
                .Columns(x).EditorComponent = cboAccountCategory
                .Columns(x).Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList
            Case accountTypeId
                .Columns(x).Header.Caption = "Type"
                .Columns(x).Width = 90
                .Columns(x).Header.Appearance.TextHAlign = Infragistics.Win.HAlign.Center
                .Columns(x).Header.VisiblePosition = 1
                .Columns(x).CellActivation = Activation.AllowEdit
                .Columns(x).EditorComponent = cboAccountType
                .Columns(x).Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList  
        End Select
    Next
End With

我尝试在添加新行时设置单元格值,但这不起作用。

e.Cell.Row.Cells(x).Value = "Main"

我也尝试过设置组合框的值,但没有奏效。

cboAccountCategory.Value = 1

是否可以从后面的代码中设置/更改组合框值?

4

1 回答 1

0

您应该设置网格单元格的值。您可以在网格的 InitializeRow 事件中这样做,如下所示:

Private Sub grdUserAccounts_InitializeRow(sender As Object, e As InitializeRowEventArgs) Handles grdUserAccounts.InitializeRow
    e.Row.Cells(accountCategoryId).Value = "Main"
End Sub

我已经对此进行了测试,它对我有用。

于 2016-07-16T19:21:12.943 回答