1

I have two UltraCombo items that I am trying to set the selected index on during form load that are bound to a UltraGrid EditorComponent like so...

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

I've tried setting the cell value when a new row is being added but that didn't work.

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

I've also tried setting the value of the combo boxes and that didn't work.

cboAccountCategory.Value = 1

Is it possible to set/change combo box values from code behind?

Xss
  • 211
  • 1
  • 12

1 Answers1

0

You should set the value of the grid's cell. You can do so in grid's InitializeRow event like this:

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

I've tested this and it works on my side.

wnvko
  • 1,985
  • 1
  • 14
  • 18