簡體   English   中英

將UltraCombo選中的索引綁定到UltraGrid EditorComponent時設置它

[英]Set UltraCombo selected index when its bound to UltraGrid EditorComponent

我有兩個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

是否可以從代碼后面設置/更改組合框值?

您應該設置網格單元格的值。 您可以在網格的InitializeRow事件中執行此操作,如下所示:

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

我已經測試了這個,它在我身邊起作用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM