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
2094
Grid Change Default Editor for Date Fields
posted

Is there a way to change the default editor for Dates in UltrawinGrid?

I do not want to display the monthcalendar editor. I simply want it to appears as a text field.

I am trying the following code but it doesn't seem to override it. The calendar control still appears.

    Private Sub UltraGrid1_InitializeRow(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles UltraGrid1.InitializeRow

        'Create the Settings Object:
        Dim theSettings As New DefaultEditorOwnerSettings

        'as well as the Editor Owner:
        Dim theOwner As New DefaultEditorOwner(theSettings)

        Dim theEditor As EmbeddableEditorBase = Nothing

        For Each gridCell As Infragistics.Win.UltraWinGrid.UltraGridCell In e.Row.Cells
            Dim theValue As Object = gridCell.Value

            'Create an appropriate editor based on the
            'Value's Data Type:
            If TypeOf theValue Is Boolean Then

                theSettings.DataType = GetType(Boolean)
                theEditor = New CheckEditor(theOwner)

            ElseIf TypeOf theValue Is Color Then

                theSettings.DataType = GetType(Color)
                theEditor = New ColorPickerEditor(theOwner)

            ElseIf TypeOf theValue Is String Then

                theSettings.DataType = GetType(String)
                theEditor = New EditorWithText(theOwner)

            ElseIf TypeOf theValue Is DateTime Then

                theSettings.DataType = GetType(DateTime)
                theEditor = New EditorWithText(theOwner)
            End If
        Next

        'Assign it to the Cell.Editor
        e.Row.Cells(0).Editor = theEditor

    End Sub

FYI I am also override the CellClickAction to do a rowselect because I do not want the user to be able to select/edit any cell value.

Is there any way to set a global override for the default editor rather than on row initialize?

 

Thanks In Advance!

 

  • 469350
    Offline posted

    Hi,

    I don't see any reason why the code you have here should not work, but in any case, this is extremely inefficient. I'm not sure why you are using InitializeRow for this - unless your column DataType is object and you have different data types in each cell of the same column.

    Typically, all of the cell in a column are the same type, so you could simply use the InitializeLayout event and examine the DataType of the column and set the Editor on the that. Or better yet, set the Style property on the column.

  • 2094
    Offline posted

    I decided to make the entire grid Read only

    Me.UltraGrid1.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False

    However I would still like to know how to make the dates appear as just text columns.

    Thanks
    Aaron