Home Forums WinForms controls Xceed Grid for WinForms How to use datepicker in cellviewer Reply To: How to use datepicker in cellviewer

Xceed Support
Member
Post count: 5658

Hi Kai,

To achieve the behavior you want, you must treat the CellViewManager and the CellEditorManager differently. I have edited your code to fit your needs.

————————-

Public Sub CreateTestGrid()
        Dim NewCol As New Xceed.Grid.Column(“Test”, GetType(Date))
        GridControl1.Columns.Add(NewCol)

        Dim FormatDateComponent As New System.Globalization.DateTimeFormatInfo
        FormatDateComponent.ShortDatePattern = “MMM yyyy”

        NewCol = New Xceed.Grid.Column(“Test2”, GetType(Date))
        Dim dtpEditor As New DateTimePicker
        dtpEditor.Format = DateTimePickerFormat.Custom
        dtpEditor.CustomFormat = “MMM yyyy”
        Dim dtpViewer As New DateTimePicker
        dtpViewer.Format = DateTimePickerFormat.Custom

        dtpViewer.CustomFormat = “MMM yyyy”

        Dim dateEditor As New DateEditor()

        NewCol.CellEditorManager = New CellEditorManager(dtpEditor, “Value”, True, True)

        NewCol.FormatSpecifier = “d”
        NewCol.FormatProvider = FormatDateComponent

        GridControl1.Columns.Add(NewCol)

        Dim Row As Xceed.Grid.DataRow
        Row = GridControl1.DataRows.AddNew()
        Row.Cells(0).Value = Now
        Row.Cells(1).Value = Now
        Row.EndEdit()
    End Sub

————————-

Imported from legacy forums. Posted by Marc [Xceed] (had 396 views)