Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
EditorWithCombo ValueList not populating
posted

I'm trying to set the editor for all the cells in the 1st row of my grid (which happens to be fixed).  I think I'm doing this right, but for some reason I can't get the settings to pass up the valuelist to the editor...

 

    Private Sub grdDatasource_InitializeRow(sender As Object, e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles grdDatasource.InitializeRow
        If grdDatasource.Rows.FixedRows.Contains(e.Row) Then
            Dim theSettings As New DefaultEditorOwnerSettings
            Dim MyDropdownList As New UltraDropDown
            Dim tblList As New DataTable
            tblList.Columns.Add("ColName")
            tblList.Rows.Add("col1")
            tblList.Rows.Add("col2")
            MyDropdownList.SetDataBinding(tblList, "ColName")

            MyDropdownList.ValueMember = "ColName"
            MyDropdownList.DisplayMember = "ColName"
            theSettings.ValueList = MyDropdownList

            For Each CurrentCell As Infragistics.Win.UltraWinGrid.UltraGridCell In e.Row.Cells
                Dim mySettings As New DefaultEditorOwnerSettings()
                mySettings.ValueList = MyDropdownList
                Dim myEditor As New EditorWithCombo(New DefaultEditorOwner(mySettings))
                CurrentCell.Editor = myEditor
            Next
        End If
    End Sub

 

 

 

mySettings.Valuelist appears to have the proper list bound to the table, but once I create the meEditor object, passing in the mySettings, the valuelist becomes NOTHING.

Any idea why the Editor isn't picking up the Valuelist from the settings object?

 

Parents
  • 469350
    Offline posted

    Not every control supports every property of the DefaultEditorOwnerSettings.So it's possible the grid is not honoring the ValueList you are specifying here.

    The good news is that you really don't need this, anyway. You can simple set the ValueList property on the cell.

    Another potential problem here is that you are creating a new UltraDropDown and a new DataTable for every row every time that row is initialized. This is a problem for a number of reasons. For one thing, your UltraDropdown is never parented to the form. This means it will never get disposed and it also has no BindingContext.

    This is also horribly inefficient, since you are creating a huge number of UltraDropDowns and DataTables that will never get disposed. Your application will eat up more and more memory the longer it runs.

    I strongly recommend creating the UltraDropdown only once and doing it outside of the InitializeRow event. If you need more than one UltraDropDown, then I would create all the ones you need and re-use them as needed inside InitializeRow. And also make sure to add the UltraDropDown control to the form.Controls collection. 

    So you can replace your loop with this code:

    For Each CurrentCell As Infragistics.Win.UltraWinGrid.UltraGridCell In e.Row.Cells
                    CurrentCell.ValueList = MyDropdownList

                    CurrentCell.Editor = myEditor
                Next

    And you do not need the DefaultEditorOwnerSettings at all.

Reply Children
No Data